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