blob: 939f7503e8dbbd9903b13d7073133359dfc96dde [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>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053015
Lee Jones3510ec62012-02-06 11:22:26 -080016extern struct amba_device *
17dbx500_add_amba_device(struct device *parent, const char *name,
18 resource_size_t base, int irq, void *pdata,
19 unsigned int periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053020
21struct spi_master_cntlr;
22
23static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080024dbx500_add_msp_spi(struct device *parent, const char *name,
25 resource_size_t base, int irq,
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053026 struct spi_master_cntlr *pdata)
27{
Lee Jones18403422012-02-06 11:22:21 -080028 return dbx500_add_amba_device(parent, name, base, irq,
29 pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053030}
31
32static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080033dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
34 int irq, struct spi_master_cntlr *pdata,
Linus Walleij72930312011-03-24 16:13:13 +010035 u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053036{
Lee Jones18403422012-02-06 11:22:21 -080037 return dbx500_add_amba_device(parent, name, base, irq,
38 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053039}
40
41struct mmci_platform_data;
42
43static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080044dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
45 int irq, struct mmci_platform_data *pdata, u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053046{
Lee Jones18403422012-02-06 11:22:21 -080047 return dbx500_add_amba_device(parent, name, base, irq,
48 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053049}
50
Linus Walleij5d7b8462010-10-14 13:57:59 +020051struct amba_pl011_data;
52
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053053static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080054dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
55 int irq, struct amba_pl011_data *pdata)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053056{
Lee Jones18403422012-02-06 11:22:21 -080057 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053058}
59
60struct nmk_i2c_controller;
61
62static inline struct platform_device *
Lee Jones18403422012-02-06 11:22:21 -080063dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
Lee Jones3510ec62012-02-06 11:22:26 -080064 struct nmk_i2c_controller *data)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053065{
Lee Jones3510ec62012-02-06 11:22:26 -080066 struct resource res[] = {
67 DEFINE_RES_MEM(base, SZ_4K),
68 DEFINE_RES_IRQ(irq),
69 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053070
Lee Jones3510ec62012-02-06 11:22:26 -080071 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 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053081
Lee Jones3510ec62012-02-06 11:22:26 -080082 return platform_device_register_full(&pdevinfo);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053083}
84
85static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080086dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053087{
Lee Jones18403422012-02-06 11:22:21 -080088 return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053089}
90
Rabin Vincent01afdd12010-12-08 11:07:55 +053091struct nmk_gpio_platform_data;
92
Lee Jones18403422012-02-06 11:22:21 -080093void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
94 int irq, struct nmk_gpio_platform_data *pdata);
Rabin Vincent01afdd12010-12-08 11:07:55 +053095
Linus Walleije98ea772012-04-26 23:57:25 +020096static inline void
97dbx500_add_pinctrl(struct device *parent, const char *name)
98{
99 struct platform_device_info pdevinfo = {
100 .parent = parent,
101 .name = name,
102 .id = -1,
103 };
104
105 platform_device_register_full(&pdevinfo);
106}
107
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530108#endif