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
11 #include <linux/platform_device.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/sys_soc.h>
14 #include <plat/i2c.h>
15
16 extern struct amba_device *
17 dbx500_add_amba_device(struct device *parent, const char *name,
18 resource_size_t base, int irq, void *pdata,
19 unsigned int periphid);
20
21 struct spi_master_cntlr;
22
23 static inline struct amba_device *
dbx500_add_msp_spi(struct device * parent,const char * name,resource_size_t base,int irq,struct spi_master_cntlr * pdata)24 dbx500_add_msp_spi(struct device *parent, const char *name,
25 resource_size_t base, int irq,
26 struct spi_master_cntlr *pdata)
27 {
28 return dbx500_add_amba_device(parent, name, base, irq,
29 pdata, 0);
30 }
31
32 static inline struct amba_device *
dbx500_add_spi(struct device * parent,const char * name,resource_size_t base,int irq,struct spi_master_cntlr * pdata,u32 periphid)33 dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
34 int irq, struct spi_master_cntlr *pdata,
35 u32 periphid)
36 {
37 return dbx500_add_amba_device(parent, name, base, irq,
38 pdata, periphid);
39 }
40
41 struct mmci_platform_data;
42
43 static inline struct amba_device *
dbx500_add_sdi(struct device * parent,const char * name,resource_size_t base,int irq,struct mmci_platform_data * pdata,u32 periphid)44 dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
45 int irq, struct mmci_platform_data *pdata, u32 periphid)
46 {
47 return dbx500_add_amba_device(parent, name, base, irq,
48 pdata, periphid);
49 }
50
51 struct amba_pl011_data;
52
53 static inline struct amba_device *
dbx500_add_uart(struct device * parent,const char * name,resource_size_t base,int irq,struct amba_pl011_data * pdata)54 dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
55 int irq, struct amba_pl011_data *pdata)
56 {
57 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
58 }
59
60 struct nmk_i2c_controller;
61
62 static inline struct platform_device *
dbx500_add_i2c(struct device * parent,int id,resource_size_t base,int irq,struct nmk_i2c_controller * data)63 dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
64 struct nmk_i2c_controller *data)
65 {
66 struct resource res[] = {
67 DEFINE_RES_MEM(base, SZ_4K),
68 DEFINE_RES_IRQ(irq),
69 };
70
71 struct platform_device_info pdevinfo = {
72 .parent = parent,
73 .name = "nmk-i2c",
74 .id = id,
75 .res = res,
76 .num_res = ARRAY_SIZE(res),
77 .data = data,
78 .size_data = sizeof(*data),
79 .dma_mask = DMA_BIT_MASK(32),
80 };
81
82 return platform_device_register_full(&pdevinfo);
83 }
84
85 static inline struct amba_device *
dbx500_add_rtc(struct device * parent,resource_size_t base,int irq)86 dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
87 {
88 return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0);
89 }
90
91 struct nmk_gpio_platform_data;
92
93 void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
94 int irq, struct nmk_gpio_platform_data *pdata);
95
96 #endif
97