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> |
Linus Walleij | 08956a0 | 2012-04-03 12:00:18 +0100 | [diff] [blame^] | 14 | #include <linux/amba/bus.h> |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 15 | #include <plat/i2c.h> |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 16 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 17 | struct spi_master_cntlr; |
| 18 | |
| 19 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 20 | dbx500_add_msp_spi(struct device *parent, const char *name, |
| 21 | resource_size_t base, int irq, |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 22 | struct spi_master_cntlr *pdata) |
| 23 | { |
Linus Walleij | 08956a0 | 2012-04-03 12:00:18 +0100 | [diff] [blame^] | 24 | return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, |
| 25 | pdata, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 29 | dbx500_add_spi(struct device *parent, const char *name, resource_size_t base, |
| 30 | int irq, struct spi_master_cntlr *pdata, |
Linus Walleij | 7293031 | 2011-03-24 16:13:13 +0100 | [diff] [blame] | 31 | u32 periphid) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 32 | { |
Linus Walleij | 08956a0 | 2012-04-03 12:00:18 +0100 | [diff] [blame^] | 33 | return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, |
| 34 | pdata, periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | struct mmci_platform_data; |
| 38 | |
| 39 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 40 | dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base, |
| 41 | int irq, struct mmci_platform_data *pdata, u32 periphid) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 42 | { |
Linus Walleij | 08956a0 | 2012-04-03 12:00:18 +0100 | [diff] [blame^] | 43 | return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, |
| 44 | pdata, periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 45 | } |
| 46 | |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 47 | struct amba_pl011_data; |
| 48 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 49 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 50 | dbx500_add_uart(struct device *parent, const char *name, resource_size_t base, |
| 51 | int irq, struct amba_pl011_data *pdata) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 52 | { |
Linus Walleij | 08956a0 | 2012-04-03 12:00:18 +0100 | [diff] [blame^] | 53 | return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, pdata, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | struct nmk_i2c_controller; |
| 57 | |
| 58 | static inline struct platform_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 59 | 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] | 60 | struct nmk_i2c_controller *data) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 61 | { |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 62 | struct resource res[] = { |
| 63 | DEFINE_RES_MEM(base, SZ_4K), |
| 64 | DEFINE_RES_IRQ(irq), |
| 65 | }; |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 66 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 67 | struct platform_device_info pdevinfo = { |
| 68 | .parent = parent, |
| 69 | .name = "nmk-i2c", |
| 70 | .id = id, |
| 71 | .res = res, |
| 72 | .num_res = ARRAY_SIZE(res), |
| 73 | .data = data, |
| 74 | .size_data = sizeof(*data), |
| 75 | .dma_mask = DMA_BIT_MASK(32), |
| 76 | }; |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 77 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 78 | return platform_device_register_full(&pdevinfo); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 82 | dbx500_add_rtc(struct device *parent, resource_size_t base, int irq) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 83 | { |
Linus Walleij | 08956a0 | 2012-04-03 12:00:18 +0100 | [diff] [blame^] | 84 | return amba_apb_device_add(parent, "rtc-pl031", base, SZ_4K, irq, |
| 85 | 0, NULL, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 86 | } |
| 87 | |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 88 | struct nmk_gpio_platform_data; |
| 89 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 90 | void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, |
| 91 | int irq, struct nmk_gpio_platform_data *pdata); |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 92 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 93 | #endif |