blob: 89c5a59b3295e0e0b725c50e9a70dc18a6986875 [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>
14#include <plat/i2c.h>
Andreas Westin585d1882012-05-10 10:14:06 +020015#include <mach/crypto-ux500.h>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053016
Lee Jones3510ec62012-02-06 11:22:26 -080017extern struct amba_device *
18dbx500_add_amba_device(struct device *parent, const char *name,
19 resource_size_t base, int irq, void *pdata,
20 unsigned int periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053021
Andreas Westin585d1882012-05-10 10:14:06 +020022extern struct platform_device *
23dbx500_add_platform_device_noirq(const char *name, int id,
24 resource_size_t base, void *pdata);
25
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053026struct spi_master_cntlr;
27
28static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080029dbx500_add_msp_spi(struct device *parent, const char *name,
30 resource_size_t base, int irq,
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053031 struct spi_master_cntlr *pdata)
32{
Lee Jones18403422012-02-06 11:22:21 -080033 return dbx500_add_amba_device(parent, name, base, irq,
34 pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053035}
36
37static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080038dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
39 int irq, struct spi_master_cntlr *pdata,
Linus Walleij72930312011-03-24 16:13:13 +010040 u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053041{
Lee Jones18403422012-02-06 11:22:21 -080042 return dbx500_add_amba_device(parent, name, base, irq,
43 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053044}
45
46struct mmci_platform_data;
47
48static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080049dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
50 int irq, struct mmci_platform_data *pdata, u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053051{
Lee Jones18403422012-02-06 11:22:21 -080052 return dbx500_add_amba_device(parent, name, base, irq,
53 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053054}
55
Linus Walleij5d7b8462010-10-14 13:57:59 +020056struct amba_pl011_data;
57
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053058static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080059dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
60 int irq, struct amba_pl011_data *pdata)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053061{
Lee Jones18403422012-02-06 11:22:21 -080062 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053063}
64
65struct nmk_i2c_controller;
66
67static inline struct platform_device *
Lee Jones18403422012-02-06 11:22:21 -080068dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
Lee Jones3510ec62012-02-06 11:22:26 -080069 struct nmk_i2c_controller *data)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053070{
Lee Jones3510ec62012-02-06 11:22:26 -080071 struct resource res[] = {
72 DEFINE_RES_MEM(base, SZ_4K),
73 DEFINE_RES_IRQ(irq),
74 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053075
Lee Jones3510ec62012-02-06 11:22:26 -080076 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 Vincentfbf1eadf2010-09-29 19:46:32 +053086
Lee Jones3510ec62012-02-06 11:22:26 -080087 return platform_device_register_full(&pdevinfo);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053088}
89
90static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080091dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053092{
Lee Jones18403422012-02-06 11:22:21 -080093 return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053094}
95
Andreas Westin585d1882012-05-10 10:14:06 +020096struct cryp_platform_data;
97
98static inline struct platform_device *
99dbx500_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
121struct hash_platform_data;
122
123static inline struct platform_device *
124dbx500_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 Vincent01afdd12010-12-08 11:07:55 +0530145struct nmk_gpio_platform_data;
146
Lee Jones18403422012-02-06 11:22:21 -0800147void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
148 int irq, struct nmk_gpio_platform_data *pdata);
Rabin Vincent01afdd12010-12-08 11:07:55 +0530149
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530150#endif