blob: 6e47065602669a3a4c720417137f768763c13363 [file] [log] [blame]
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +05301/*
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 Jones3510ec62012-02-06 11:22:26 -080011#include <linux/platform_device.h>
12#include <linux/dma-mapping.h>
13#include <linux/sys_soc.h>
Linus Walleij08956a02012-04-03 12:00:18 +010014#include <linux/amba/bus.h>
Lee Jones3510ec62012-02-06 11:22:26 -080015#include <plat/i2c.h>
Andreas Westin585d1882012-05-10 10:14:06 +020016#include <mach/crypto-ux500.h>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053017
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053018struct spi_master_cntlr;
19
20static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080021dbx500_add_msp_spi(struct device *parent, const char *name,
22 resource_size_t base, int irq,
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053023 struct spi_master_cntlr *pdata)
24{
Linus Walleij08956a02012-04-03 12:00:18 +010025 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
26 pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053027}
28
29static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080030dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
31 int irq, struct spi_master_cntlr *pdata,
Linus Walleij72930312011-03-24 16:13:13 +010032 u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053033{
Linus Walleij08956a02012-04-03 12:00:18 +010034 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
35 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053036}
37
38struct mmci_platform_data;
39
40static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080041dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
42 int irq, struct mmci_platform_data *pdata, u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053043{
Linus Walleij08956a02012-04-03 12:00:18 +010044 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
45 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053046}
47
Linus Walleij5d7b8462010-10-14 13:57:59 +020048struct amba_pl011_data;
49
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053050static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080051dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
52 int irq, struct amba_pl011_data *pdata)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053053{
Linus Walleij08956a02012-04-03 12:00:18 +010054 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053055}
56
57struct nmk_i2c_controller;
58
59static inline struct platform_device *
Lee Jones18403422012-02-06 11:22:21 -080060dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
Lee Jones3510ec62012-02-06 11:22:26 -080061 struct nmk_i2c_controller *data)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053062{
Lee Jones3510ec62012-02-06 11:22:26 -080063 struct resource res[] = {
64 DEFINE_RES_MEM(base, SZ_4K),
65 DEFINE_RES_IRQ(irq),
66 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053067
Lee Jones3510ec62012-02-06 11:22:26 -080068 struct platform_device_info pdevinfo = {
69 .parent = parent,
70 .name = "nmk-i2c",
71 .id = id,
72 .res = res,
73 .num_res = ARRAY_SIZE(res),
74 .data = data,
75 .size_data = sizeof(*data),
76 .dma_mask = DMA_BIT_MASK(32),
77 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053078
Lee Jones3510ec62012-02-06 11:22:26 -080079 return platform_device_register_full(&pdevinfo);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053080}
81
82static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080083dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053084{
Linus Walleij08956a02012-04-03 12:00:18 +010085 return amba_apb_device_add(parent, "rtc-pl031", base, SZ_4K, irq,
86 0, NULL, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053087}
88
Andreas Westin585d1882012-05-10 10:14:06 +020089struct cryp_platform_data;
90
91static inline struct platform_device *
92dbx500_add_cryp1(struct device *parent, int id, resource_size_t base, int irq,
93 struct cryp_platform_data *pdata)
94{
95 struct resource res[] = {
96 DEFINE_RES_MEM(base, SZ_4K),
97 DEFINE_RES_IRQ(irq),
98 };
99
100 struct platform_device_info pdevinfo = {
101 .parent = parent,
102 .name = "cryp1",
103 .id = id,
104 .res = res,
105 .num_res = ARRAY_SIZE(res),
106 .data = pdata,
107 .size_data = sizeof(*pdata),
108 .dma_mask = DMA_BIT_MASK(32),
109 };
110
111 return platform_device_register_full(&pdevinfo);
112}
113
114struct hash_platform_data;
115
116static inline struct platform_device *
117dbx500_add_hash1(struct device *parent, int id, resource_size_t base,
118 struct hash_platform_data *pdata)
119{
120 struct resource res[] = {
121 DEFINE_RES_MEM(base, SZ_4K),
122 };
123
124 struct platform_device_info pdevinfo = {
125 .parent = parent,
126 .name = "hash1",
127 .id = id,
128 .res = res,
129 .num_res = ARRAY_SIZE(res),
130 .data = pdata,
131 .size_data = sizeof(*pdata),
132 .dma_mask = DMA_BIT_MASK(32),
133 };
134
135 return platform_device_register_full(&pdevinfo);
136}
137
Rabin Vincent01afdd12010-12-08 11:07:55 +0530138struct nmk_gpio_platform_data;
139
Lee Jones18403422012-02-06 11:22:21 -0800140void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
141 int irq, struct nmk_gpio_platform_data *pdata);
Rabin Vincent01afdd12010-12-08 11:07:55 +0530142
Linus Walleije98ea772012-04-26 23:57:25 +0200143static inline void
144dbx500_add_pinctrl(struct device *parent, const char *name)
145{
146 struct platform_device_info pdevinfo = {
147 .parent = parent,
148 .name = name,
149 .id = -1,
150 };
151
152 platform_device_register_full(&pdevinfo);
153}
154
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530155#endif