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> |
Kishon Vijay Abraham I | 459bc97 | 2012-10-27 19:05:56 +0530 | [diff] [blame] | 22 | #include <linux/platform_data/omap_ocp2scp.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" |
Lokesh Vutla | d5e7c86 | 2012-10-15 14:03:51 -0700 | [diff] [blame] | 39 | #include "dma.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 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 68 | return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; |
sricharan | 0abcf61 | 2011-02-08 14:10:45 +0530 | [diff] [blame] | 69 | } |
| 70 | postcore_initcall(omap3_l3_init); |
| 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 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 102 | return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; |
sricharan | a4dc616 | 2011-03-09 16:00:29 +0530 | [diff] [blame] | 103 | } |
| 104 | postcore_initcall(omap4_l3_init); |
| 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 | |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 286 | #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_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; |
Felipe Contreras | 69dbf85 | 2011-02-24 12:51:33 -0800 | [diff] [blame] | 291 | |
| 292 | oh = omap_hwmod_lookup("mailbox"); |
| 293 | if (!oh) { |
| 294 | pr_err("%s: unable to find hwmod\n", __func__); |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 295 | return; |
| 296 | } |
Felipe Contreras | 69dbf85 | 2011-02-24 12:51:33 -0800 | [diff] [blame] | 297 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 298 | pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 299 | WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n", |
| 300 | __func__, PTR_ERR(pdev)); |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 301 | } |
| 302 | #else |
| 303 | static inline void omap_init_mbox(void) { } |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 304 | #endif /* CONFIG_OMAP_MBOX_FWK */ |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 305 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 306 | static inline void omap_init_sti(void) {} |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 307 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 308 | #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE) |
| 309 | |
| 310 | static struct platform_device omap_pcm = { |
| 311 | .name = "omap-pcm-audio", |
| 312 | .id = -1, |
| 313 | }; |
| 314 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 315 | static void omap_init_audio(void) |
| 316 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 317 | platform_device_register(&omap_pcm); |
| 318 | } |
| 319 | |
| 320 | #else |
| 321 | static inline void omap_init_audio(void) {} |
| 322 | #endif |
| 323 | |
Peter Ujfalusi | d231f5c | 2011-02-12 22:28:56 -0600 | [diff] [blame] | 324 | #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \ |
| 325 | defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE) |
| 326 | |
Kevin Hilman | 9cf793f | 2012-02-20 09:43:30 -0800 | [diff] [blame] | 327 | static void __init omap_init_mcpdm(void) |
Peter Ujfalusi | d231f5c | 2011-02-12 22:28:56 -0600 | [diff] [blame] | 328 | { |
| 329 | struct omap_hwmod *oh; |
Peter Ujfalusi | 927dbbb | 2011-11-03 10:41:22 +0200 | [diff] [blame] | 330 | struct platform_device *pdev; |
Peter Ujfalusi | d231f5c | 2011-02-12 22:28:56 -0600 | [diff] [blame] | 331 | |
| 332 | oh = omap_hwmod_lookup("mcpdm"); |
| 333 | if (!oh) { |
| 334 | printk(KERN_ERR "Could not look up mcpdm hw_mod\n"); |
| 335 | return; |
| 336 | } |
| 337 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 338 | pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0); |
Peter Ujfalusi | 927dbbb | 2011-11-03 10:41:22 +0200 | [diff] [blame] | 339 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n"); |
Peter Ujfalusi | d231f5c | 2011-02-12 22:28:56 -0600 | [diff] [blame] | 340 | } |
| 341 | #else |
| 342 | static inline void omap_init_mcpdm(void) {} |
| 343 | #endif |
| 344 | |
Peter Ujfalusi | de9eb09 | 2011-12-13 10:48:54 -0800 | [diff] [blame] | 345 | #if defined(CONFIG_SND_OMAP_SOC_DMIC) || \ |
| 346 | defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE) |
| 347 | |
Kevin Hilman | 9cf793f | 2012-02-20 09:43:30 -0800 | [diff] [blame] | 348 | static void __init omap_init_dmic(void) |
Peter Ujfalusi | de9eb09 | 2011-12-13 10:48:54 -0800 | [diff] [blame] | 349 | { |
| 350 | struct omap_hwmod *oh; |
| 351 | struct platform_device *pdev; |
| 352 | |
| 353 | oh = omap_hwmod_lookup("dmic"); |
| 354 | if (!oh) { |
Sebastien Guiriec | 49c58e8 | 2012-10-16 11:19:17 -0700 | [diff] [blame] | 355 | pr_err("Could not look up dmic hw_mod\n"); |
Peter Ujfalusi | de9eb09 | 2011-12-13 10:48:54 -0800 | [diff] [blame] | 356 | return; |
| 357 | } |
| 358 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 359 | pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0); |
Peter Ujfalusi | de9eb09 | 2011-12-13 10:48:54 -0800 | [diff] [blame] | 360 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n"); |
| 361 | } |
| 362 | #else |
| 363 | static inline void omap_init_dmic(void) {} |
| 364 | #endif |
| 365 | |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 366 | #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \ |
| 367 | defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE) |
| 368 | |
| 369 | static struct platform_device omap_hdmi_audio = { |
| 370 | .name = "omap-hdmi-audio", |
| 371 | .id = -1, |
| 372 | }; |
| 373 | |
| 374 | static void __init omap_init_hdmi_audio(void) |
| 375 | { |
| 376 | struct omap_hwmod *oh; |
| 377 | struct platform_device *pdev; |
| 378 | |
| 379 | oh = omap_hwmod_lookup("dss_hdmi"); |
| 380 | if (!oh) { |
| 381 | printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n"); |
| 382 | return; |
| 383 | } |
| 384 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 385 | pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0, 0); |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 386 | WARN(IS_ERR(pdev), |
| 387 | "Can't build omap_device for omap-hdmi-audio-dai.\n"); |
| 388 | |
| 389 | platform_device_register(&omap_hdmi_audio); |
| 390 | } |
| 391 | #else |
| 392 | static inline void omap_init_hdmi_audio(void) {} |
| 393 | #endif |
| 394 | |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 395 | #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 396 | |
Arnd Bergmann | 2203747 | 2012-08-24 15:21:06 +0200 | [diff] [blame] | 397 | #include <linux/platform_data/spi-omap2-mcspi.h> |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 398 | |
Kevin Hilman | 9cf793f | 2012-02-20 09:43:30 -0800 | [diff] [blame] | 399 | static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused) |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 400 | { |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 401 | struct platform_device *pdev; |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 402 | char *name = "omap2_mcspi"; |
| 403 | struct omap2_mcspi_platform_config *pdata; |
| 404 | static int spi_num; |
| 405 | struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr; |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 406 | |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 407 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); |
| 408 | if (!pdata) { |
| 409 | pr_err("Memory allocation for McSPI device failed\n"); |
| 410 | return -ENOMEM; |
| 411 | } |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 412 | |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 413 | pdata->num_cs = mcspi_attrib->num_chipselect; |
| 414 | switch (oh->class->rev) { |
| 415 | case OMAP2_MCSPI_REV: |
| 416 | case OMAP3_MCSPI_REV: |
| 417 | pdata->regs_offset = 0; |
| 418 | break; |
| 419 | case OMAP4_MCSPI_REV: |
| 420 | pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET; |
| 421 | break; |
| 422 | default: |
| 423 | pr_err("Invalid McSPI Revision value\n"); |
Julia Lawall | e0feca89 | 2011-12-23 18:39:31 +0100 | [diff] [blame] | 424 | kfree(pdata); |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 425 | return -EINVAL; |
| 426 | } |
| 427 | |
| 428 | spi_num++; |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 429 | pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata)); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 430 | 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] | 431 | name, oh->name); |
| 432 | kfree(pdata); |
| 433 | return 0; |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 434 | } |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 435 | |
| 436 | static void omap_init_mcspi(void) |
| 437 | { |
Charulatha V | 1a5d819 | 2011-02-02 17:52:14 +0530 | [diff] [blame] | 438 | omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL); |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | #else |
| 442 | static inline void omap_init_mcspi(void) {} |
| 443 | #endif |
| 444 | |
Paul Walmsley | 4848d46 | 2012-09-23 17:28:27 -0600 | [diff] [blame] | 445 | /** |
| 446 | * omap_init_rng - bind the RNG hwmod to the RNG omap_device |
| 447 | * |
| 448 | * Bind the RNG hwmod to the RNG omap_device. No return value. |
| 449 | */ |
| 450 | static void omap_init_rng(void) |
| 451 | { |
| 452 | struct omap_hwmod *oh; |
| 453 | struct platform_device *pdev; |
| 454 | |
| 455 | oh = omap_hwmod_lookup("rng"); |
| 456 | if (!oh) |
| 457 | return; |
| 458 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 459 | pdev = omap_device_build("omap_rng", -1, oh, NULL, 0); |
Paul Walmsley | 4848d46 | 2012-09-23 17:28:27 -0600 | [diff] [blame] | 460 | WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n"); |
| 461 | } |
Will Deacon | 8834133 | 2010-04-09 13:54:43 +0100 | [diff] [blame] | 462 | |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 463 | #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE) |
| 464 | |
Dmitry Kasatkin | edc774e | 2010-05-14 14:45:08 +1000 | [diff] [blame] | 465 | #ifdef CONFIG_ARCH_OMAP2 |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 466 | static struct resource omap2_sham_resources[] = { |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 467 | { |
| 468 | .start = OMAP24XX_SEC_SHA1MD5_BASE, |
| 469 | .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64, |
| 470 | .flags = IORESOURCE_MEM, |
| 471 | }, |
| 472 | { |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 473 | .start = 51 + OMAP_INTC_START, |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 474 | .flags = IORESOURCE_IRQ, |
| 475 | } |
| 476 | }; |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 477 | static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources); |
| 478 | #else |
| 479 | #define omap2_sham_resources NULL |
| 480 | #define omap2_sham_resources_sz 0 |
| 481 | #endif |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 482 | |
Dmitry Kasatkin | edc774e | 2010-05-14 14:45:08 +1000 | [diff] [blame] | 483 | #ifdef CONFIG_ARCH_OMAP3 |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 484 | static struct resource omap3_sham_resources[] = { |
| 485 | { |
| 486 | .start = OMAP34XX_SEC_SHA1MD5_BASE, |
| 487 | .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64, |
| 488 | .flags = IORESOURCE_MEM, |
| 489 | }, |
| 490 | { |
Tony Lindgren | 7d7e1eb | 2012-08-27 17:43:01 -0700 | [diff] [blame] | 491 | .start = 49 + OMAP_INTC_START, |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 492 | .flags = IORESOURCE_IRQ, |
| 493 | }, |
| 494 | { |
| 495 | .start = OMAP34XX_DMA_SHA1MD5_RX, |
| 496 | .flags = IORESOURCE_DMA, |
| 497 | } |
| 498 | }; |
| 499 | static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources); |
| 500 | #else |
| 501 | #define omap3_sham_resources NULL |
| 502 | #define omap3_sham_resources_sz 0 |
| 503 | #endif |
| 504 | |
| 505 | static struct platform_device sham_device = { |
| 506 | .name = "omap-sham", |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 507 | .id = -1, |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 508 | }; |
| 509 | |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 510 | static void omap_init_sham(void) |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 511 | { |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 512 | if (cpu_is_omap24xx()) { |
| 513 | sham_device.resource = omap2_sham_resources; |
| 514 | sham_device.num_resources = omap2_sham_resources_sz; |
| 515 | } else if (cpu_is_omap34xx()) { |
| 516 | sham_device.resource = omap3_sham_resources; |
| 517 | sham_device.num_resources = omap3_sham_resources_sz; |
| 518 | } else { |
| 519 | pr_err("%s: platform not supported\n", __func__); |
| 520 | return; |
| 521 | } |
| 522 | platform_device_register(&sham_device); |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 523 | } |
| 524 | #else |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 525 | static inline void omap_init_sham(void) { } |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 526 | #endif |
| 527 | |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 528 | #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE) |
| 529 | |
Dmitry Kasatkin | 82a0c14 | 2010-08-20 13:44:46 +0000 | [diff] [blame] | 530 | #ifdef CONFIG_ARCH_OMAP2 |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 531 | static struct resource omap2_aes_resources[] = { |
| 532 | { |
| 533 | .start = OMAP24XX_SEC_AES_BASE, |
| 534 | .end = OMAP24XX_SEC_AES_BASE + 0x4C, |
| 535 | .flags = IORESOURCE_MEM, |
| 536 | }, |
| 537 | { |
| 538 | .start = OMAP24XX_DMA_AES_TX, |
| 539 | .flags = IORESOURCE_DMA, |
| 540 | }, |
| 541 | { |
| 542 | .start = OMAP24XX_DMA_AES_RX, |
| 543 | .flags = IORESOURCE_DMA, |
| 544 | } |
| 545 | }; |
| 546 | static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources); |
| 547 | #else |
| 548 | #define omap2_aes_resources NULL |
| 549 | #define omap2_aes_resources_sz 0 |
| 550 | #endif |
| 551 | |
Dmitry Kasatkin | 82a0c14 | 2010-08-20 13:44:46 +0000 | [diff] [blame] | 552 | #ifdef CONFIG_ARCH_OMAP3 |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 553 | static struct resource omap3_aes_resources[] = { |
| 554 | { |
| 555 | .start = OMAP34XX_SEC_AES_BASE, |
| 556 | .end = OMAP34XX_SEC_AES_BASE + 0x4C, |
| 557 | .flags = IORESOURCE_MEM, |
| 558 | }, |
| 559 | { |
| 560 | .start = OMAP34XX_DMA_AES2_TX, |
| 561 | .flags = IORESOURCE_DMA, |
| 562 | }, |
| 563 | { |
| 564 | .start = OMAP34XX_DMA_AES2_RX, |
| 565 | .flags = IORESOURCE_DMA, |
| 566 | } |
| 567 | }; |
| 568 | static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources); |
| 569 | #else |
| 570 | #define omap3_aes_resources NULL |
| 571 | #define omap3_aes_resources_sz 0 |
| 572 | #endif |
| 573 | |
| 574 | static struct platform_device aes_device = { |
| 575 | .name = "omap-aes", |
| 576 | .id = -1, |
| 577 | }; |
| 578 | |
| 579 | static void omap_init_aes(void) |
| 580 | { |
| 581 | if (cpu_is_omap24xx()) { |
| 582 | aes_device.resource = omap2_aes_resources; |
| 583 | aes_device.num_resources = omap2_aes_resources_sz; |
| 584 | } else if (cpu_is_omap34xx()) { |
| 585 | aes_device.resource = omap3_aes_resources; |
| 586 | aes_device.num_resources = omap3_aes_resources_sz; |
| 587 | } else { |
| 588 | pr_err("%s: platform not supported\n", __func__); |
| 589 | return; |
| 590 | } |
| 591 | platform_device_register(&aes_device); |
| 592 | } |
| 593 | |
| 594 | #else |
| 595 | static inline void omap_init_aes(void) { } |
| 596 | #endif |
| 597 | |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 598 | /*-------------------------------------------------------------------------*/ |
| 599 | |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 600 | #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \ |
| 601 | defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE) |
| 602 | #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) |
| 603 | static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = { |
| 604 | }; |
| 605 | #else |
| 606 | static struct resource omap_vout_resource[2] = { |
| 607 | }; |
| 608 | #endif |
| 609 | |
| 610 | static struct platform_device omap_vout_device = { |
| 611 | .name = "omap_vout", |
| 612 | .num_resources = ARRAY_SIZE(omap_vout_resource), |
| 613 | .resource = &omap_vout_resource[0], |
| 614 | .id = -1, |
| 615 | }; |
| 616 | static void omap_init_vout(void) |
| 617 | { |
| 618 | if (platform_device_register(&omap_vout_device) < 0) |
| 619 | printk(KERN_ERR "Unable to register OMAP-VOUT device\n"); |
| 620 | } |
| 621 | #else |
| 622 | static inline void omap_init_vout(void) {} |
| 623 | #endif |
| 624 | |
Kishon Vijay Abraham I | 459bc97 | 2012-10-27 19:05:56 +0530 | [diff] [blame] | 625 | #if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE) |
| 626 | static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev) |
| 627 | { |
| 628 | int cnt = 0; |
| 629 | |
| 630 | while (ocp2scp_dev->drv_name != NULL) { |
| 631 | cnt++; |
| 632 | ocp2scp_dev++; |
| 633 | } |
| 634 | |
| 635 | return cnt; |
| 636 | } |
| 637 | |
Tony Lindgren | e407ee0 | 2013-01-21 10:17:03 -0800 | [diff] [blame] | 638 | static void __init omap_init_ocp2scp(void) |
Kishon Vijay Abraham I | 459bc97 | 2012-10-27 19:05:56 +0530 | [diff] [blame] | 639 | { |
| 640 | struct omap_hwmod *oh; |
| 641 | struct platform_device *pdev; |
| 642 | int bus_id = -1, dev_cnt = 0, i; |
| 643 | struct omap_ocp2scp_dev *ocp2scp_dev; |
| 644 | const char *oh_name, *name; |
| 645 | struct omap_ocp2scp_platform_data *pdata; |
| 646 | |
| 647 | if (!cpu_is_omap44xx()) |
| 648 | return; |
| 649 | |
| 650 | oh_name = "ocp2scp_usb_phy"; |
| 651 | name = "omap-ocp2scp"; |
| 652 | |
| 653 | oh = omap_hwmod_lookup(oh_name); |
| 654 | if (!oh) { |
| 655 | pr_err("%s: could not find omap_hwmod for %s\n", __func__, |
| 656 | oh_name); |
| 657 | return; |
| 658 | } |
| 659 | |
| 660 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); |
| 661 | if (!pdata) { |
| 662 | pr_err("%s: No memory for ocp2scp pdata\n", __func__); |
| 663 | return; |
| 664 | } |
| 665 | |
| 666 | ocp2scp_dev = oh->dev_attr; |
| 667 | dev_cnt = count_ocp2scp_devices(ocp2scp_dev); |
| 668 | |
| 669 | if (!dev_cnt) { |
| 670 | pr_err("%s: No devices connected to ocp2scp\n", __func__); |
| 671 | kfree(pdata); |
| 672 | return; |
| 673 | } |
| 674 | |
| 675 | pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *) |
| 676 | * dev_cnt, GFP_KERNEL); |
| 677 | if (!pdata->devices) { |
| 678 | pr_err("%s: No memory for ocp2scp pdata devices\n", __func__); |
| 679 | kfree(pdata); |
| 680 | return; |
| 681 | } |
| 682 | |
| 683 | for (i = 0; i < dev_cnt; i++, ocp2scp_dev++) |
| 684 | pdata->devices[i] = ocp2scp_dev; |
| 685 | |
| 686 | pdata->dev_cnt = dev_cnt; |
| 687 | |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame^] | 688 | pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata)); |
Kishon Vijay Abraham I | 459bc97 | 2012-10-27 19:05:56 +0530 | [diff] [blame] | 689 | if (IS_ERR(pdev)) { |
| 690 | pr_err("Could not build omap_device for %s %s\n", |
| 691 | name, oh_name); |
| 692 | kfree(pdata->devices); |
| 693 | kfree(pdata); |
| 694 | return; |
| 695 | } |
| 696 | } |
| 697 | #else |
| 698 | static inline void omap_init_ocp2scp(void) { } |
| 699 | #endif |
| 700 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 701 | /*-------------------------------------------------------------------------*/ |
| 702 | |
| 703 | static int __init omap2_init_devices(void) |
| 704 | { |
Matt Porter | 484202f | 2012-09-17 16:26:11 -0700 | [diff] [blame] | 705 | /* Enable dummy states for those platforms without pinctrl support */ |
| 706 | if (!of_have_populated_dt()) |
| 707 | pinctrl_provide_dummies(); |
| 708 | |
Paul Walmsley | 81fbc5ef | 2010-12-21 19:56:17 -0700 | [diff] [blame] | 709 | /* |
| 710 | * please keep these calls, and their implementations above, |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 711 | * in alphabetical order so they're easier to sort through. |
| 712 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 713 | omap_init_audio(); |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 714 | omap_init_camera(); |
Ricardo Neri | 5eeec21 | 2012-05-09 14:19:14 -0700 | [diff] [blame] | 715 | omap_init_hdmi_audio(); |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 716 | omap_init_mbox(); |
Benoit Cousson | efcf1e5 | 2012-01-20 14:15:58 +0100 | [diff] [blame] | 717 | /* If dtb is there, the devices will be created dynamically */ |
Peter Ujfalusi | 259bd6c | 2012-05-02 15:23:18 +0300 | [diff] [blame] | 718 | if (!of_have_populated_dt()) { |
| 719 | omap_init_dmic(); |
Peter Ujfalusi | 4b21ffc | 2012-05-02 15:23:19 +0300 | [diff] [blame] | 720 | omap_init_mcpdm(); |
Benoit Cousson | efcf1e5 | 2012-01-20 14:15:58 +0100 | [diff] [blame] | 721 | omap_init_mcspi(); |
Peter Ujfalusi | 259bd6c | 2012-05-02 15:23:18 +0300 | [diff] [blame] | 722 | } |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 723 | omap_init_sti(); |
Paul Walmsley | 4848d46 | 2012-09-23 17:28:27 -0600 | [diff] [blame] | 724 | omap_init_rng(); |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 725 | omap_init_sham(); |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 726 | omap_init_aes(); |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 727 | omap_init_vout(); |
Kishon Vijay Abraham I | 459bc97 | 2012-10-27 19:05:56 +0530 | [diff] [blame] | 728 | omap_init_ocp2scp(); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 729 | |
| 730 | return 0; |
| 731 | } |
| 732 | arch_initcall(omap2_init_devices); |