blob: f75bcb2ab13b96890430f4bab8acbf7751959051 [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>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053016
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053017struct spi_master_cntlr;
18
19static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080020dbx500_add_msp_spi(struct device *parent, const char *name,
21 resource_size_t base, int irq,
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053022 struct spi_master_cntlr *pdata)
23{
Linus Walleij08956a02012-04-03 12:00:18 +010024 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
25 pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053026}
27
28static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080029dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
30 int irq, struct spi_master_cntlr *pdata,
Linus Walleij72930312011-03-24 16:13:13 +010031 u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053032{
Linus Walleij08956a02012-04-03 12:00:18 +010033 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
34 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053035}
36
37struct mmci_platform_data;
38
39static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080040dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
41 int irq, struct mmci_platform_data *pdata, u32 periphid)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053042{
Linus Walleij08956a02012-04-03 12:00:18 +010043 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0,
44 pdata, periphid);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053045}
46
Linus Walleij5d7b8462010-10-14 13:57:59 +020047struct amba_pl011_data;
48
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053049static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080050dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
51 int irq, struct amba_pl011_data *pdata)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053052{
Linus Walleij08956a02012-04-03 12:00:18 +010053 return amba_ahb_device_add(parent, name, base, SZ_4K, irq, 0, pdata, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053054}
55
56struct nmk_i2c_controller;
57
58static inline struct platform_device *
Lee Jones18403422012-02-06 11:22:21 -080059dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
Lee Jones3510ec62012-02-06 11:22:26 -080060 struct nmk_i2c_controller *data)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053061{
Lee Jones3510ec62012-02-06 11:22:26 -080062 struct resource res[] = {
63 DEFINE_RES_MEM(base, SZ_4K),
64 DEFINE_RES_IRQ(irq),
65 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053066
Lee Jones3510ec62012-02-06 11:22:26 -080067 struct platform_device_info pdevinfo = {
68 .parent = parent,
69 .name = "nmk-i2c",
70 .id = id,
71 .res = res,
72 .num_res = ARRAY_SIZE(res),
73 .data = data,
74 .size_data = sizeof(*data),
75 .dma_mask = DMA_BIT_MASK(32),
76 };
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053077
Lee Jones3510ec62012-02-06 11:22:26 -080078 return platform_device_register_full(&pdevinfo);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053079}
80
81static inline struct amba_device *
Lee Jones18403422012-02-06 11:22:21 -080082dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053083{
Linus Walleij08956a02012-04-03 12:00:18 +010084 return amba_apb_device_add(parent, "rtc-pl031", base, SZ_4K, irq,
85 0, NULL, 0);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053086}
87
Rabin Vincent01afdd12010-12-08 11:07:55 +053088struct nmk_gpio_platform_data;
89
Lee Jones18403422012-02-06 11:22:21 -080090void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
91 int irq, struct nmk_gpio_platform_data *pdata);
Rabin Vincent01afdd12010-12-08 11:07:55 +053092
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053093#endif