Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) ST-Ericsson SA 2010 |
| 3 | * |
| 4 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson |
| 5 | * License terms: GNU General Public License (GPL), version 2. |
| 6 | */ |
| 7 | |
| 8 | #ifndef __DEVICES_COMMON_H |
| 9 | #define __DEVICES_COMMON_H |
| 10 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/dma-mapping.h> |
| 13 | #include <linux/sys_soc.h> |
| 14 | #include <plat/i2c.h> |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 15 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 16 | extern struct amba_device * |
| 17 | dbx500_add_amba_device(struct device *parent, const char *name, |
| 18 | resource_size_t base, int irq, void *pdata, |
| 19 | unsigned int periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 20 | |
| 21 | struct spi_master_cntlr; |
| 22 | |
| 23 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 24 | dbx500_add_msp_spi(struct device *parent, const char *name, |
| 25 | resource_size_t base, int irq, |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 26 | struct spi_master_cntlr *pdata) |
| 27 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 28 | return dbx500_add_amba_device(parent, name, base, irq, |
| 29 | pdata, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 33 | dbx500_add_spi(struct device *parent, const char *name, resource_size_t base, |
| 34 | int irq, struct spi_master_cntlr *pdata, |
Linus Walleij | 7293031 | 2011-03-24 16:13:13 +0100 | [diff] [blame] | 35 | u32 periphid) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 36 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 37 | return dbx500_add_amba_device(parent, name, base, irq, |
| 38 | pdata, periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | struct mmci_platform_data; |
| 42 | |
| 43 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 44 | dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base, |
| 45 | int irq, struct mmci_platform_data *pdata, u32 periphid) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 46 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 47 | return dbx500_add_amba_device(parent, name, base, irq, |
| 48 | pdata, periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 49 | } |
| 50 | |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 51 | struct amba_pl011_data; |
| 52 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 53 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 54 | dbx500_add_uart(struct device *parent, const char *name, resource_size_t base, |
| 55 | int irq, struct amba_pl011_data *pdata) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 56 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 57 | return dbx500_add_amba_device(parent, name, base, irq, pdata, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | struct nmk_i2c_controller; |
| 61 | |
| 62 | static inline struct platform_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 63 | dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq, |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 64 | struct nmk_i2c_controller *data) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 65 | { |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 66 | struct resource res[] = { |
| 67 | DEFINE_RES_MEM(base, SZ_4K), |
| 68 | DEFINE_RES_IRQ(irq), |
| 69 | }; |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 70 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 71 | struct platform_device_info pdevinfo = { |
| 72 | .parent = parent, |
| 73 | .name = "nmk-i2c", |
| 74 | .id = id, |
| 75 | .res = res, |
| 76 | .num_res = ARRAY_SIZE(res), |
| 77 | .data = data, |
| 78 | .size_data = sizeof(*data), |
| 79 | .dma_mask = DMA_BIT_MASK(32), |
| 80 | }; |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 81 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 82 | return platform_device_register_full(&pdevinfo); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 86 | dbx500_add_rtc(struct device *parent, resource_size_t base, int irq) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 87 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 88 | return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 89 | } |
| 90 | |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 91 | struct nmk_gpio_platform_data; |
| 92 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 93 | void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, |
| 94 | int irq, struct nmk_gpio_platform_data *pdata); |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 95 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 96 | #endif |