Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/devices.c |
| 3 | * |
| 4 | * OMAP2 platform device setup/initialization |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | */ |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 11 | #include <linux/gpio.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 15 | #include <linux/io.h> |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 16 | #include <linux/clk.h> |
Varadarajan, Charulatha | f2ce623 | 2010-09-23 20:02:42 +0530 | [diff] [blame] | 17 | #include <linux/err.h> |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 18 | #include <linux/slab.h> |
Benoit Cousson | ad8dfac | 2011-08-12 13:48:47 +0200 | [diff] [blame] | 19 | #include <linux/of.h> |
Matt Porter | 484202f | 2012-09-17 16:26:11 -0700 | [diff] [blame] | 20 | #include <linux/pinctrl/machine.h> |
Felipe Balbi | 0f1142a | 2012-03-16 22:47:48 -0700 | [diff] [blame] | 21 | #include <linux/platform_data/omap4-keypad.h> |
Suman Anna | b8a7cf8 | 2013-01-28 17:21:58 -0600 | [diff] [blame] | 22 | #include <linux/platform_data/mailbox-omap.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 23 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 24 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/map.h> |
| 26 | |
Tony Lindgren | 45c3eb7 | 2012-11-30 08:41:50 -0800 | [diff] [blame] | 27 | #include <linux/omap-dma.h> |
Tony Lindgren | 2a296c8 | 2012-10-02 17:41:35 -0700 | [diff] [blame] | 28 | |
Tony Lindgren | ee0839c | 2012-02-24 10:34:35 -0800 | [diff] [blame] | 29 | #include "iomap.h" |
Tony Lindgren | 2a296c8 | 2012-10-02 17:41:35 -0700 | [diff] [blame] | 30 | #include "omap_hwmod.h" |
Tony Lindgren | 25c7d49 | 2012-10-02 17:25:48 -0700 | [diff] [blame] | 31 | #include "omap_device.h" |
Tony Lindgren | 0e70156 | 2012-09-20 11:42:20 -0700 | [diff] [blame] | 32 | #include "omap4-keypad.h" |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 33 | |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 34 | #include "soc.h" |
| 35 | #include "common.h" |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 36 | #include "mux.h" |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 37 | #include "control.h" |
Laurent Pinchart | a11f670 | 2009-12-14 08:09:07 -0300 | [diff] [blame] | 38 | #include "devices.h" |
Archit Taneja | 576e5bd | 2013-09-16 12:48:31 +0530 | [diff] [blame] | 39 | #include "display.h" |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 40 | |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 41 | #define L3_MODULES_MAX_LEN 12 |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 42 | #define L3_MODULES 3 |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 43 | |
| 44 | static int __init omap3_l3_init(void) |
| 45 | { |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 46 | struct omap_hwmod *oh; |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 47 | struct platform_device *pdev; |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 48 | char oh_name[L3_MODULES_MAX_LEN]; |
| 49 | |
| 50 | /* |
| 51 | * To avoid code running on other OMAPs in |
| 52 | * multi-omap builds |
| 53 | */ |
| 54 | if (!(cpu_is_omap34xx())) |
| 55 | return -ENODEV; |
| 56 | |
Paul Walmsley | eeb3711 | 2012-04-13 06:34:32 -0600 | [diff] [blame] | 57 | snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main"); |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 58 | |
| 59 | oh = omap_hwmod_lookup(oh_name); |
| 60 | |
| 61 | if (!oh) |
| 62 | pr_err("could not look up %s\n", oh_name); |
| 63 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 64 | pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0); |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 65 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 66 | WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 67 | |
Thomas Meyer | 1261674 | 2013-06-01 11:44:44 +0200 | [diff] [blame] | 68 | return PTR_RET(pdev); |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 69 | } |
Tony Lindgren | b76c8b1 | 2013-01-11 11:24:18 -0800 | [diff] [blame] | 70 | omap_postcore_initcall(omap3_l3_init); |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 71 | |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 72 | static int __init omap4_l3_init(void) |
| 73 | { |
Paul Walmsley | eeb3711 | 2012-04-13 06:34:32 -0600 | [diff] [blame] | 74 | int i; |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 75 | struct omap_hwmod *oh[3]; |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 76 | struct platform_device *pdev; |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 77 | char oh_name[L3_MODULES_MAX_LEN]; |
| 78 | |
Benoit Cousson | ad8dfac | 2011-08-12 13:48:47 +0200 | [diff] [blame] | 79 | /* If dtb is there, the devices will be created dynamically */ |
| 80 | if (of_have_populated_dt()) |
| 81 | return -ENODEV; |
| 82 | |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 83 | /* |
| 84 | * To avoid code running on other OMAPs in |
| 85 | * multi-omap builds |
| 86 | */ |
R Sricharan | e17933c | 2011-11-04 15:52:59 +0530 | [diff] [blame] | 87 | if (!cpu_is_omap44xx() && !soc_is_omap54xx()) |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 88 | return -ENODEV; |
| 89 | |
| 90 | for (i = 0; i < L3_MODULES; i++) { |
Paul Walmsley | eeb3711 | 2012-04-13 06:34:32 -0600 | [diff] [blame] | 91 | snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1); |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 92 | |
| 93 | oh[i] = omap_hwmod_lookup(oh_name); |
| 94 | if (!(oh[i])) |
| 95 | pr_err("could not look up %s\n", oh_name); |
| 96 | } |
| 97 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 98 | pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0); |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 99 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 100 | WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 101 | |
Thomas Meyer | 1261674 | 2013-06-01 11:44:44 +0200 | [diff] [blame] | 102 | return PTR_RET(pdev); |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 103 | } |
Tony Lindgren | b76c8b1 | 2013-01-11 11:24:18 -0800 | [diff] [blame] | 104 | omap_postcore_initcall(omap4_l3_init); |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 105 | |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 106 | #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 107 | |
Sergio Aguirre | cfe2cde | 2010-11-15 11:29:54 -0300 | [diff] [blame] | 108 | static struct resource omap2cam_resources[] = { |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 109 | { |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 110 | .start = OMAP24XX_CAMERA_BASE, |
| 111 | .end = OMAP24XX_CAMERA_BASE + 0xfff, |
| 112 | .flags = IORESOURCE_MEM, |
| 113 | }, |
| 114 | { |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 115 | .start = 24 + OMAP_INTC_START, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 116 | .flags = IORESOURCE_IRQ, |
| 117 | } |
| 118 | }; |
| 119 | |
Sergio Aguirre | cfe2cde | 2010-11-15 11:29:54 -0300 | [diff] [blame] | 120 | static struct platform_device omap2cam_device = { |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 121 | .name = "omap24xxcam", |
| 122 | .id = -1, |
Sergio Aguirre | cfe2cde | 2010-11-15 11:29:54 -0300 | [diff] [blame] | 123 | .num_resources = ARRAY_SIZE(omap2cam_resources), |
| 124 | .resource = omap2cam_resources, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 125 | }; |
Laurent Pinchart | a11f670 | 2009-12-14 08:09:07 -0300 | [diff] [blame] | 126 | #endif |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 127 | |
Ohad Ben-Cohen | 1a51a0c | 2012-01-11 15:28:11 +0200 | [diff] [blame] | 128 | #if defined(CONFIG_IOMMU_API) |
| 129 | |
Tony Lindgren | 2ab7c84 | 2012-11-02 12:24:14 -0700 | [diff] [blame] | 130 | #include <linux/platform_data/iommu-omap.h> |
Ohad Ben-Cohen | 1a51a0c | 2012-01-11 15:28:11 +0200 | [diff] [blame] | 131 | |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 132 | static struct resource omap3isp_resources[] = { |
| 133 | { |
| 134 | .start = OMAP3430_ISP_BASE, |
| 135 | .end = OMAP3430_ISP_END, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, |
| 138 | { |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 139 | .start = OMAP3430_ISP_CCP2_BASE, |
| 140 | .end = OMAP3430_ISP_CCP2_END, |
| 141 | .flags = IORESOURCE_MEM, |
| 142 | }, |
| 143 | { |
| 144 | .start = OMAP3430_ISP_CCDC_BASE, |
| 145 | .end = OMAP3430_ISP_CCDC_END, |
| 146 | .flags = IORESOURCE_MEM, |
| 147 | }, |
| 148 | { |
| 149 | .start = OMAP3430_ISP_HIST_BASE, |
| 150 | .end = OMAP3430_ISP_HIST_END, |
| 151 | .flags = IORESOURCE_MEM, |
| 152 | }, |
| 153 | { |
| 154 | .start = OMAP3430_ISP_H3A_BASE, |
| 155 | .end = OMAP3430_ISP_H3A_END, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | }, |
| 158 | { |
| 159 | .start = OMAP3430_ISP_PREV_BASE, |
| 160 | .end = OMAP3430_ISP_PREV_END, |
| 161 | .flags = IORESOURCE_MEM, |
| 162 | }, |
| 163 | { |
| 164 | .start = OMAP3430_ISP_RESZ_BASE, |
| 165 | .end = OMAP3430_ISP_RESZ_END, |
| 166 | .flags = IORESOURCE_MEM, |
| 167 | }, |
| 168 | { |
| 169 | .start = OMAP3430_ISP_SBL_BASE, |
| 170 | .end = OMAP3430_ISP_SBL_END, |
| 171 | .flags = IORESOURCE_MEM, |
| 172 | }, |
| 173 | { |
Tuukka Toivonen | 6817a69 | 2010-02-02 11:17:33 -0300 | [diff] [blame] | 174 | .start = OMAP3430_ISP_CSI2A_REGS1_BASE, |
| 175 | .end = OMAP3430_ISP_CSI2A_REGS1_END, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 176 | .flags = IORESOURCE_MEM, |
| 177 | }, |
| 178 | { |
Tuukka Toivonen | 6817a69 | 2010-02-02 11:17:33 -0300 | [diff] [blame] | 179 | .start = OMAP3430_ISP_CSIPHY2_BASE, |
| 180 | .end = OMAP3430_ISP_CSIPHY2_END, |
| 181 | .flags = IORESOURCE_MEM, |
| 182 | }, |
| 183 | { |
| 184 | .start = OMAP3630_ISP_CSI2A_REGS2_BASE, |
| 185 | .end = OMAP3630_ISP_CSI2A_REGS2_END, |
| 186 | .flags = IORESOURCE_MEM, |
| 187 | }, |
| 188 | { |
| 189 | .start = OMAP3630_ISP_CSI2C_REGS1_BASE, |
| 190 | .end = OMAP3630_ISP_CSI2C_REGS1_END, |
| 191 | .flags = IORESOURCE_MEM, |
| 192 | }, |
| 193 | { |
| 194 | .start = OMAP3630_ISP_CSIPHY1_BASE, |
| 195 | .end = OMAP3630_ISP_CSIPHY1_END, |
| 196 | .flags = IORESOURCE_MEM, |
| 197 | }, |
| 198 | { |
| 199 | .start = OMAP3630_ISP_CSI2C_REGS2_BASE, |
| 200 | .end = OMAP3630_ISP_CSI2C_REGS2_END, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 201 | .flags = IORESOURCE_MEM, |
| 202 | }, |
| 203 | { |
Sakari Ailus | c19d19e | 2012-10-14 07:31:48 -0300 | [diff] [blame] | 204 | .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE, |
| 205 | .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3, |
| 206 | .flags = IORESOURCE_MEM, |
| 207 | }, |
| 208 | { |
| 209 | .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL, |
| 210 | .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3, |
| 211 | .flags = IORESOURCE_MEM, |
| 212 | }, |
| 213 | { |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 214 | .start = 24 + OMAP_INTC_START, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 215 | .flags = IORESOURCE_IRQ, |
| 216 | } |
| 217 | }; |
| 218 | |
| 219 | static struct platform_device omap3isp_device = { |
| 220 | .name = "omap3isp", |
| 221 | .id = -1, |
| 222 | .num_resources = ARRAY_SIZE(omap3isp_resources), |
| 223 | .resource = omap3isp_resources, |
| 224 | }; |
| 225 | |
Ohad Ben-Cohen | c8eaab3 | 2011-09-23 16:44:57 +0300 | [diff] [blame] | 226 | static struct omap_iommu_arch_data omap3_isp_iommu = { |
Omar Ramirez Luna | 72b15b6 | 2012-11-19 19:05:50 -0600 | [diff] [blame] | 227 | .name = "mmu_isp", |
Ohad Ben-Cohen | c8eaab3 | 2011-09-23 16:44:57 +0300 | [diff] [blame] | 228 | }; |
| 229 | |
Laurent Pinchart | a11f670 | 2009-12-14 08:09:07 -0300 | [diff] [blame] | 230 | int omap3_init_camera(struct isp_platform_data *pdata) |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 231 | { |
Laurent Pinchart | a11f670 | 2009-12-14 08:09:07 -0300 | [diff] [blame] | 232 | omap3isp_device.dev.platform_data = pdata; |
Ohad Ben-Cohen | c8eaab3 | 2011-09-23 16:44:57 +0300 | [diff] [blame] | 233 | omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu; |
| 234 | |
Laurent Pinchart | a11f670 | 2009-12-14 08:09:07 -0300 | [diff] [blame] | 235 | return platform_device_register(&omap3isp_device); |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 236 | } |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 237 | |
Ohad Ben-Cohen | 1a51a0c | 2012-01-11 15:28:11 +0200 | [diff] [blame] | 238 | #else /* !CONFIG_IOMMU_API */ |
| 239 | |
| 240 | int omap3_init_camera(struct isp_platform_data *pdata) |
| 241 | { |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | #endif |
| 246 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 247 | static inline void omap_init_camera(void) |
| 248 | { |
Sergio Aguirre | cfe2cde | 2010-11-15 11:29:54 -0300 | [diff] [blame] | 249 | #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) |
| 250 | if (cpu_is_omap24xx()) |
| 251 | platform_device_register(&omap2cam_device); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 252 | #endif |
Sergio Aguirre | cfe2cde | 2010-11-15 11:29:54 -0300 | [diff] [blame] | 253 | } |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 254 | |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 255 | int __init omap4_keyboard_init(struct omap4_keypad_platform_data |
Shubhrajyoti Datta | f67df6c | 2011-07-05 03:38:24 -0700 | [diff] [blame] | 256 | *sdp4430_keypad_data, struct omap_board_data *bdata) |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 257 | { |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 258 | struct platform_device *pdev; |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 259 | struct omap_hwmod *oh; |
| 260 | struct omap4_keypad_platform_data *keypad_data; |
| 261 | unsigned int id = -1; |
| 262 | char *oh_name = "kbd"; |
| 263 | char *name = "omap4-keypad"; |
| 264 | |
| 265 | oh = omap_hwmod_lookup(oh_name); |
| 266 | if (!oh) { |
| 267 | pr_err("Could not look up %s\n", oh_name); |
| 268 | return -ENODEV; |
| 269 | } |
| 270 | |
| 271 | keypad_data = sdp4430_keypad_data; |
| 272 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 273 | pdev = omap_device_build(name, id, oh, keypad_data, |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 274 | sizeof(struct omap4_keypad_platform_data)); |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 275 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 276 | if (IS_ERR(pdev)) { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 277 | WARN(1, "Can't build omap_device for %s:%s.\n", |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 278 | name, oh->name); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 279 | return PTR_ERR(pdev); |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 280 | } |
Shubhrajyoti Datta | f67df6c | 2011-07-05 03:38:24 -0700 | [diff] [blame] | 281 | oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt); |
Syed Rafiuddin | 5955676 | 2010-12-27 05:51:45 +0000 | [diff] [blame] | 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
Suman Anna | c869c75 | 2013-03-12 17:55:29 -0500 | [diff] [blame] | 286 | #if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE) |
Kevin Hilman | 9cf793f | 2012-02-20 09:43:30 -0800 | [diff] [blame] | 287 | static inline void __init omap_init_mbox(void) |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 288 | { |
Felipe Contreras | 69dbf85 | 2011-02-24 12:51:33 -0800 | [diff] [blame] | 289 | struct omap_hwmod *oh; |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 290 | struct platform_device *pdev; |
Suman Anna | b8a7cf8 | 2013-01-28 17:21:58 -0600 | [diff] [blame] | 291 | struct omap_mbox_pdata *pdata; |
Felipe Contreras | 69dbf85 | 2011-02-24 12:51:33 -0800 | [diff] [blame] | 292 | |
| 293 | oh = omap_hwmod_lookup("mailbox"); |
| 294 | if (!oh) { |
| 295 | pr_err("%s: unable to find hwmod\n", __func__); |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 296 | return; |
| 297 | } |
Suman Anna | b8a7cf8 | 2013-01-28 17:21:58 -0600 | [diff] [blame] | 298 | if (!oh->dev_attr) { |
| 299 | pr_err("%s: hwmod doesn't have valid attrs\n", __func__); |
| 300 | return; |
| 301 | } |
Felipe Contreras | 69dbf85 | 2011-02-24 12:51:33 -0800 | [diff] [blame] | 302 | |
Suman Anna | b8a7cf8 | 2013-01-28 17:21:58 -0600 | [diff] [blame] | 303 | pdata = (struct omap_mbox_pdata *)oh->dev_attr; |
| 304 | pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata)); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 305 | WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n", |
| 306 | __func__, PTR_ERR(pdev)); |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 307 | } |
| 308 | #else |
| 309 | static inline void omap_init_mbox(void) { } |
Suman Anna | c869c75 | 2013-03-12 17:55:29 -0500 | [diff] [blame] | 310 | #endif /* CONFIG_OMAP2PLUS_MBOX */ |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 311 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 312 | static inline void omap_init_sti(void) {} |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 313 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 314 | #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE) |
| 315 | |
| 316 | static struct platform_device omap_pcm = { |
| 317 | .name = "omap-pcm-audio", |
| 318 | .id = -1, |
| 319 | }; |
| 320 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 321 | static void omap_init_audio(void) |
| 322 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 323 | platform_device_register(&omap_pcm); |
| 324 | } |
| 325 | |
| 326 | #else |
| 327 | static inline void omap_init_audio(void) {} |
| 328 | #endif |
| 329 | |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 330 | #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \ |
| 331 | defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE) |
| 332 | |
| 333 | static struct platform_device omap_hdmi_audio = { |
| 334 | .name = "omap-hdmi-audio", |
| 335 | .id = -1, |
| 336 | }; |
| 337 | |
| 338 | static void __init omap_init_hdmi_audio(void) |
| 339 | { |
| 340 | struct omap_hwmod *oh; |
| 341 | struct platform_device *pdev; |
| 342 | |
| 343 | oh = omap_hwmod_lookup("dss_hdmi"); |
Peter Ujfalusi | 7252db5 | 2013-06-11 10:32:00 +0200 | [diff] [blame] | 344 | if (!oh) |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 345 | return; |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 346 | |
Paul Walmsley | 6efc3fe | 2013-02-12 03:58:35 +0000 | [diff] [blame] | 347 | pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0); |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 348 | WARN(IS_ERR(pdev), |
| 349 | "Can't build omap_device for omap-hdmi-audio-dai.\n"); |
| 350 | |
| 351 | platform_device_register(&omap_hdmi_audio); |
| 352 | } |
| 353 | #else |
| 354 | static inline void omap_init_hdmi_audio(void) {} |
| 355 | #endif |
| 356 | |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 357 | #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 358 | |
Arnd Bergmann | 2203747 | 2012-08-24 15:21:06 +0200 | [diff] [blame] | 359 | #include <linux/platform_data/spi-omap2-mcspi.h> |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 360 | |
Kevin Hilman | 9cf793f | 2012-02-20 09:43:30 -0800 | [diff] [blame] | 361 | static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused) |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 362 | { |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 363 | struct platform_device *pdev; |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 364 | char *name = "omap2_mcspi"; |
| 365 | struct omap2_mcspi_platform_config *pdata; |
| 366 | static int spi_num; |
| 367 | struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr; |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 368 | |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 369 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); |
| 370 | if (!pdata) { |
| 371 | pr_err("Memory allocation for McSPI device failed\n"); |
| 372 | return -ENOMEM; |
| 373 | } |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 374 | |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 375 | pdata->num_cs = mcspi_attrib->num_chipselect; |
| 376 | switch (oh->class->rev) { |
| 377 | case OMAP2_MCSPI_REV: |
| 378 | case OMAP3_MCSPI_REV: |
| 379 | pdata->regs_offset = 0; |
| 380 | break; |
| 381 | case OMAP4_MCSPI_REV: |
| 382 | pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET; |
| 383 | break; |
| 384 | default: |
| 385 | pr_err("Invalid McSPI Revision value\n"); |
Julia Lawall | e0feca89 | 2011-12-23 18:39:31 +0100 | [diff] [blame] | 386 | kfree(pdata); |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 387 | return -EINVAL; |
| 388 | } |
| 389 | |
| 390 | spi_num++; |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 391 | pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata)); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 392 | WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n", |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 393 | name, oh->name); |
| 394 | kfree(pdata); |
| 395 | return 0; |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 396 | } |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 397 | |
| 398 | static void omap_init_mcspi(void) |
| 399 | { |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 400 | omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL); |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | #else |
| 404 | static inline void omap_init_mcspi(void) {} |
| 405 | #endif |
| 406 | |
Paul Walmsley | 4848d46 | 2012-09-23 17:28:27 -0600 | [diff] [blame] | 407 | /** |
| 408 | * omap_init_rng - bind the RNG hwmod to the RNG omap_device |
| 409 | * |
| 410 | * Bind the RNG hwmod to the RNG omap_device. No return value. |
| 411 | */ |
| 412 | static void omap_init_rng(void) |
| 413 | { |
| 414 | struct omap_hwmod *oh; |
| 415 | struct platform_device *pdev; |
| 416 | |
| 417 | oh = omap_hwmod_lookup("rng"); |
| 418 | if (!oh) |
| 419 | return; |
| 420 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 421 | pdev = omap_device_build("omap_rng", -1, oh, NULL, 0); |
Paul Walmsley | 4848d46 | 2012-09-23 17:28:27 -0600 | [diff] [blame] | 422 | WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n"); |
| 423 | } |
Will Deacon | 8834133 | 2010-04-09 13:54:43 +0100 | [diff] [blame] | 424 | |
Mark A. Greer | 26f88e6 | 2013-03-18 10:06:32 -0600 | [diff] [blame] | 425 | static void __init omap_init_sham(void) |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 426 | { |
Mark A. Greer | 8c7bb57 | 2013-03-18 10:06:33 -0600 | [diff] [blame] | 427 | struct omap_hwmod *oh; |
| 428 | struct platform_device *pdev; |
Mark A. Greer | e569e99 | 2013-03-30 15:49:19 -0600 | [diff] [blame] | 429 | |
Mark A. Greer | 8c7bb57 | 2013-03-18 10:06:33 -0600 | [diff] [blame] | 430 | oh = omap_hwmod_lookup("sham"); |
| 431 | if (!oh) |
| 432 | return; |
Mark A. Greer | e569e99 | 2013-03-30 15:49:19 -0600 | [diff] [blame] | 433 | |
Mark A. Greer | 8c7bb57 | 2013-03-18 10:06:33 -0600 | [diff] [blame] | 434 | pdev = omap_device_build("omap-sham", -1, oh, NULL, 0); |
| 435 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n"); |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 436 | } |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 437 | |
Mark A. Greer | 14ae556 | 2012-12-21 09:28:10 -0700 | [diff] [blame] | 438 | static void __init omap_init_aes(void) |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 439 | { |
Mark A. Greer | 77e2fd8 | 2012-12-21 09:28:11 -0700 | [diff] [blame] | 440 | struct omap_hwmod *oh; |
| 441 | struct platform_device *pdev; |
Mark A. Greer | 660ffd6 | 2012-12-21 09:28:09 -0700 | [diff] [blame] | 442 | |
Mark A. Greer | 77e2fd8 | 2012-12-21 09:28:11 -0700 | [diff] [blame] | 443 | oh = omap_hwmod_lookup("aes"); |
| 444 | if (!oh) |
| 445 | return; |
Mark A. Greer | 660ffd6 | 2012-12-21 09:28:09 -0700 | [diff] [blame] | 446 | |
Mark A. Greer | 77e2fd8 | 2012-12-21 09:28:11 -0700 | [diff] [blame] | 447 | pdev = omap_device_build("omap-aes", -1, oh, NULL, 0); |
| 448 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n"); |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 449 | } |
| 450 | |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 451 | /*-------------------------------------------------------------------------*/ |
| 452 | |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 453 | #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \ |
| 454 | defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE) |
| 455 | #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) |
| 456 | static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = { |
| 457 | }; |
| 458 | #else |
| 459 | static struct resource omap_vout_resource[2] = { |
| 460 | }; |
| 461 | #endif |
| 462 | |
| 463 | static struct platform_device omap_vout_device = { |
| 464 | .name = "omap_vout", |
| 465 | .num_resources = ARRAY_SIZE(omap_vout_resource), |
| 466 | .resource = &omap_vout_resource[0], |
| 467 | .id = -1, |
| 468 | }; |
Archit Taneja | 576e5bd | 2013-09-16 12:48:31 +0530 | [diff] [blame] | 469 | |
| 470 | int __init omap_init_vout(void) |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 471 | { |
Archit Taneja | 576e5bd | 2013-09-16 12:48:31 +0530 | [diff] [blame] | 472 | return platform_device_register(&omap_vout_device); |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 473 | } |
| 474 | #else |
Archit Taneja | 576e5bd | 2013-09-16 12:48:31 +0530 | [diff] [blame] | 475 | int __init omap_init_vout(void) { return 0; } |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 476 | #endif |
| 477 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 478 | /*-------------------------------------------------------------------------*/ |
| 479 | |
| 480 | static int __init omap2_init_devices(void) |
| 481 | { |
Matt Porter | 484202f | 2012-09-17 16:26:11 -0700 | [diff] [blame] | 482 | /* Enable dummy states for those platforms without pinctrl support */ |
| 483 | if (!of_have_populated_dt()) |
| 484 | pinctrl_provide_dummies(); |
| 485 | |
Paul Walmsley | 81fbc5ef | 2010-12-21 19:56:17 -0700 | [diff] [blame] | 486 | /* |
| 487 | * please keep these calls, and their implementations above, |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 488 | * in alphabetical order so they're easier to sort through. |
| 489 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 490 | omap_init_audio(); |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 491 | omap_init_camera(); |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 492 | omap_init_hdmi_audio(); |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 493 | omap_init_mbox(); |
Benoit Cousson | efcf1e5 | 2012-01-20 14:15:58 +0100 | [diff] [blame] | 494 | /* If dtb is there, the devices will be created dynamically */ |
Peter Ujfalusi | 259bd6c | 2012-05-02 15:23:18 +0300 | [diff] [blame] | 495 | if (!of_have_populated_dt()) { |
Benoit Cousson | efcf1e5 | 2012-01-20 14:15:58 +0100 | [diff] [blame] | 496 | omap_init_mcspi(); |
Mark A. Greer | 114d7a8 | 2013-03-18 10:06:33 -0600 | [diff] [blame] | 497 | omap_init_sham(); |
Mark A. Greer | 53335ac | 2012-12-21 09:28:12 -0700 | [diff] [blame] | 498 | omap_init_aes(); |
Lokesh Vutla | 674ee08 | 2013-08-05 20:17:22 +0530 | [diff] [blame] | 499 | omap_init_rng(); |
Peter Ujfalusi | 259bd6c | 2012-05-02 15:23:18 +0300 | [diff] [blame] | 500 | } |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 501 | omap_init_sti(); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 502 | |
| 503 | return 0; |
| 504 | } |
Tony Lindgren | b76c8b1 | 2013-01-11 11:24:18 -0800 | [diff] [blame] | 505 | omap_arch_initcall(omap2_init_devices); |