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> |
Andreas Westin | 585d188 | 2012-05-10 10:14:06 +0200 | [diff] [blame^] | 15 | #include <mach/crypto-ux500.h> |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 16 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 17 | extern struct amba_device * |
| 18 | dbx500_add_amba_device(struct device *parent, const char *name, |
| 19 | resource_size_t base, int irq, void *pdata, |
| 20 | unsigned int periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 21 | |
Andreas Westin | 585d188 | 2012-05-10 10:14:06 +0200 | [diff] [blame^] | 22 | extern struct platform_device * |
| 23 | dbx500_add_platform_device_noirq(const char *name, int id, |
| 24 | resource_size_t base, void *pdata); |
| 25 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 26 | struct spi_master_cntlr; |
| 27 | |
| 28 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 29 | dbx500_add_msp_spi(struct device *parent, const char *name, |
| 30 | resource_size_t base, int irq, |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 31 | struct spi_master_cntlr *pdata) |
| 32 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 33 | return dbx500_add_amba_device(parent, name, base, irq, |
| 34 | pdata, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 38 | dbx500_add_spi(struct device *parent, const char *name, resource_size_t base, |
| 39 | int irq, struct spi_master_cntlr *pdata, |
Linus Walleij | 7293031 | 2011-03-24 16:13:13 +0100 | [diff] [blame] | 40 | u32 periphid) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 41 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 42 | return dbx500_add_amba_device(parent, name, base, irq, |
| 43 | pdata, periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | struct mmci_platform_data; |
| 47 | |
| 48 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 49 | dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base, |
| 50 | int irq, struct mmci_platform_data *pdata, u32 periphid) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 51 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 52 | return dbx500_add_amba_device(parent, name, base, irq, |
| 53 | pdata, periphid); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 54 | } |
| 55 | |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 56 | struct amba_pl011_data; |
| 57 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 58 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 59 | dbx500_add_uart(struct device *parent, const char *name, resource_size_t base, |
| 60 | int irq, struct amba_pl011_data *pdata) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 61 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 62 | return dbx500_add_amba_device(parent, name, base, irq, pdata, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | struct nmk_i2c_controller; |
| 66 | |
| 67 | static inline struct platform_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 68 | 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] | 69 | struct nmk_i2c_controller *data) |
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 resource res[] = { |
| 72 | DEFINE_RES_MEM(base, SZ_4K), |
| 73 | DEFINE_RES_IRQ(irq), |
| 74 | }; |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 75 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 76 | struct platform_device_info pdevinfo = { |
| 77 | .parent = parent, |
| 78 | .name = "nmk-i2c", |
| 79 | .id = id, |
| 80 | .res = res, |
| 81 | .num_res = ARRAY_SIZE(res), |
| 82 | .data = data, |
| 83 | .size_data = sizeof(*data), |
| 84 | .dma_mask = DMA_BIT_MASK(32), |
| 85 | }; |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 86 | |
Lee Jones | 3510ec6 | 2012-02-06 11:22:26 -0800 | [diff] [blame] | 87 | return platform_device_register_full(&pdevinfo); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | static inline struct amba_device * |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 91 | dbx500_add_rtc(struct device *parent, resource_size_t base, int irq) |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 92 | { |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 93 | return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0); |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 94 | } |
| 95 | |
Andreas Westin | 585d188 | 2012-05-10 10:14:06 +0200 | [diff] [blame^] | 96 | struct cryp_platform_data; |
| 97 | |
| 98 | static inline struct platform_device * |
| 99 | dbx500_add_cryp1(struct device *parent, int id, resource_size_t base, int irq, |
| 100 | struct cryp_platform_data *pdata) |
| 101 | { |
| 102 | struct resource res[] = { |
| 103 | DEFINE_RES_MEM(base, SZ_4K), |
| 104 | DEFINE_RES_IRQ(irq), |
| 105 | }; |
| 106 | |
| 107 | struct platform_device_info pdevinfo = { |
| 108 | .parent = parent, |
| 109 | .name = "cryp1", |
| 110 | .id = id, |
| 111 | .res = res, |
| 112 | .num_res = ARRAY_SIZE(res), |
| 113 | .data = pdata, |
| 114 | .size_data = sizeof(*pdata), |
| 115 | .dma_mask = DMA_BIT_MASK(32), |
| 116 | }; |
| 117 | |
| 118 | return platform_device_register_full(&pdevinfo); |
| 119 | } |
| 120 | |
| 121 | struct hash_platform_data; |
| 122 | |
| 123 | static inline struct platform_device * |
| 124 | dbx500_add_hash1(struct device *parent, int id, resource_size_t base, |
| 125 | struct hash_platform_data *pdata) |
| 126 | { |
| 127 | struct resource res[] = { |
| 128 | DEFINE_RES_MEM(base, SZ_4K), |
| 129 | }; |
| 130 | |
| 131 | struct platform_device_info pdevinfo = { |
| 132 | .parent = parent, |
| 133 | .name = "hash1", |
| 134 | .id = id, |
| 135 | .res = res, |
| 136 | .num_res = ARRAY_SIZE(res), |
| 137 | .data = pdata, |
| 138 | .size_data = sizeof(*pdata), |
| 139 | .dma_mask = DMA_BIT_MASK(32), |
| 140 | }; |
| 141 | |
| 142 | return platform_device_register_full(&pdevinfo); |
| 143 | } |
| 144 | |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 145 | struct nmk_gpio_platform_data; |
| 146 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 147 | void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, |
| 148 | int irq, struct nmk_gpio_platform_data *pdata); |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 149 | |
Rabin Vincent | fbf1eadf | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 150 | #endif |