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