~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-mvebu/kirkwood.c

Version: ~ [ linux-5.2-rc4 ] ~ [ linux-5.1.9 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.50 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.125 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.181 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.181 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.68 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
  3  *
  4  * arch/arm/mach-mvebu/kirkwood.c
  5  *
  6  * Flattened Device Tree board initialization
  7  *
  8  * This file is licensed under the terms of the GNU General Public
  9  * License version 2.  This program is licensed "as is" without any
 10  * warranty of any kind, whether express or implied.
 11  */
 12 
 13 #include <linux/clk.h>
 14 #include <linux/kernel.h>
 15 #include <linux/init.h>
 16 #include <linux/mbus.h>
 17 #include <linux/of.h>
 18 #include <linux/of_address.h>
 19 #include <linux/of_net.h>
 20 #include <linux/of_platform.h>
 21 #include <linux/slab.h>
 22 #include <asm/hardware/cache-feroceon-l2.h>
 23 #include <asm/mach/arch.h>
 24 #include <asm/mach/map.h>
 25 #include "kirkwood.h"
 26 #include "kirkwood-pm.h"
 27 #include "common.h"
 28 
 29 static struct resource kirkwood_cpufreq_resources[] = {
 30         [0] = {
 31                 .start  = CPU_CONTROL_PHYS,
 32                 .end    = CPU_CONTROL_PHYS + 3,
 33                 .flags  = IORESOURCE_MEM,
 34         },
 35 };
 36 
 37 static struct platform_device kirkwood_cpufreq_device = {
 38         .name           = "kirkwood-cpufreq",
 39         .id             = -1,
 40         .num_resources  = ARRAY_SIZE(kirkwood_cpufreq_resources),
 41         .resource       = kirkwood_cpufreq_resources,
 42 };
 43 
 44 static void __init kirkwood_cpufreq_init(void)
 45 {
 46         platform_device_register(&kirkwood_cpufreq_device);
 47 }
 48 
 49 static struct resource kirkwood_cpuidle_resource[] = {
 50         {
 51                 .flags  = IORESOURCE_MEM,
 52                 .start  = DDR_OPERATION_BASE,
 53                 .end    = DDR_OPERATION_BASE + 3,
 54         },
 55 };
 56 
 57 static struct platform_device kirkwood_cpuidle = {
 58         .name           = "kirkwood_cpuidle",
 59         .id             = -1,
 60         .resource       = kirkwood_cpuidle_resource,
 61         .num_resources  = 1,
 62 };
 63 
 64 static void __init kirkwood_cpuidle_init(void)
 65 {
 66         platform_device_register(&kirkwood_cpuidle);
 67 }
 68 
 69 #define MV643XX_ETH_MAC_ADDR_LOW        0x0414
 70 #define MV643XX_ETH_MAC_ADDR_HIGH       0x0418
 71 
 72 static void __init kirkwood_dt_eth_fixup(void)
 73 {
 74         struct device_node *np;
 75 
 76         /*
 77          * The ethernet interfaces forget the MAC address assigned by u-boot
 78          * if the clocks are turned off. Usually, u-boot on kirkwood boards
 79          * has no DT support to properly set local-mac-address property.
 80          * As a workaround, we get the MAC address from mv643xx_eth registers
 81          * and update the port device node if no valid MAC address is set.
 82          */
 83         for_each_compatible_node(np, NULL, "marvell,kirkwood-eth-port") {
 84                 struct device_node *pnp = of_get_parent(np);
 85                 struct clk *clk;
 86                 struct property *pmac;
 87                 void __iomem *io;
 88                 u8 *macaddr;
 89                 u32 reg;
 90 
 91                 if (!pnp)
 92                         continue;
 93 
 94                 /* skip disabled nodes or nodes with valid MAC address*/
 95                 if (!of_device_is_available(pnp) || of_get_mac_address(np))
 96                         goto eth_fixup_skip;
 97 
 98                 clk = of_clk_get(pnp, 0);
 99                 if (IS_ERR(clk))
100                         goto eth_fixup_skip;
101 
102                 io = of_iomap(pnp, 0);
103                 if (!io)
104                         goto eth_fixup_no_map;
105 
106                 /* ensure port clock is not gated to not hang CPU */
107                 clk_prepare_enable(clk);
108 
109                 /* store MAC address register contents in local-mac-address */
110                 pr_err(FW_INFO "%s: local-mac-address is not set\n",
111                        np->full_name);
112 
113                 pmac = kzalloc(sizeof(*pmac) + 6, GFP_KERNEL);
114                 if (!pmac)
115                         goto eth_fixup_no_mem;
116 
117                 pmac->value = pmac + 1;
118                 pmac->length = 6;
119                 pmac->name = kstrdup("local-mac-address", GFP_KERNEL);
120                 if (!pmac->name) {
121                         kfree(pmac);
122                         goto eth_fixup_no_mem;
123                 }
124 
125                 macaddr = pmac->value;
126                 reg = readl(io + MV643XX_ETH_MAC_ADDR_HIGH);
127                 macaddr[0] = (reg >> 24) & 0xff;
128                 macaddr[1] = (reg >> 16) & 0xff;
129                 macaddr[2] = (reg >> 8) & 0xff;
130                 macaddr[3] = reg & 0xff;
131 
132                 reg = readl(io + MV643XX_ETH_MAC_ADDR_LOW);
133                 macaddr[4] = (reg >> 8) & 0xff;
134                 macaddr[5] = reg & 0xff;
135 
136                 of_update_property(np, pmac);
137 
138 eth_fixup_no_mem:
139                 iounmap(io);
140                 clk_disable_unprepare(clk);
141 eth_fixup_no_map:
142                 clk_put(clk);
143 eth_fixup_skip:
144                 of_node_put(pnp);
145         }
146 }
147 
148 /*
149  * Disable propagation of mbus errors to the CPU local bus, as this
150  * causes mbus errors (which can occur for example for PCI aborts) to
151  * throw CPU aborts, which we're not set up to deal with.
152  */
153 static void kirkwood_disable_mbus_error_propagation(void)
154 {
155         void __iomem *cpu_config;
156 
157         cpu_config = ioremap(CPU_CONFIG_PHYS, 4);
158         writel(readl(cpu_config) & ~CPU_CONFIG_ERROR_PROP, cpu_config);
159 }
160 
161 static struct of_dev_auxdata auxdata[] __initdata = {
162         OF_DEV_AUXDATA("marvell,kirkwood-audio", 0xf10a0000,
163                        "mvebu-audio", NULL),
164         { /* sentinel */ }
165 };
166 
167 static void __init kirkwood_dt_init(void)
168 {
169         kirkwood_disable_mbus_error_propagation();
170 
171         BUG_ON(mvebu_mbus_dt_init(false));
172 
173 #ifdef CONFIG_CACHE_FEROCEON_L2
174         feroceon_of_init();
175 #endif
176         kirkwood_cpufreq_init();
177         kirkwood_cpuidle_init();
178 
179         kirkwood_pm_init();
180         kirkwood_dt_eth_fixup();
181 
182         of_platform_default_populate(NULL, auxdata, NULL);
183 }
184 
185 static const char * const kirkwood_dt_board_compat[] __initconst = {
186         "marvell,kirkwood",
187         NULL
188 };
189 
190 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
191         /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
192         .init_machine   = kirkwood_dt_init,
193         .restart        = mvebu_restart,
194         .dt_compat      = kirkwood_dt_board_compat,
195 MACHINE_END
196 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp