Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0-only
  2// arch/arm/mach-orion5x/wnr854t-setup.c
 
 
 
 
 
  3#include <linux/gpio.h>
  4#include <linux/kernel.h>
  5#include <linux/init.h>
  6#include <linux/platform_device.h>
  7#include <linux/pci.h>
  8#include <linux/irq.h>
  9#include <linux/delay.h>
 10#include <linux/mtd/physmap.h>
 11#include <linux/mv643xx_eth.h>
 12#include <linux/ethtool.h>
 13#include <linux/platform_data/dsa.h>
 14#include <asm/mach-types.h>
 15#include <asm/mach/arch.h>
 16#include <asm/mach/pci.h>
 17#include "orion5x.h"
 18#include "common.h"
 19#include "mpp.h"
 20
 21static unsigned int wnr854t_mpp_modes[] __initdata = {
 22	MPP0_GPIO,		/* Power LED green (0=on) */
 23	MPP1_GPIO,		/* Reset Button (0=off) */
 24	MPP2_GPIO,		/* Power LED blink (0=off) */
 25	MPP3_GPIO,		/* WAN Status LED amber (0=off) */
 26	MPP4_GPIO,		/* PCI int */
 27	MPP5_GPIO,		/* ??? */
 28	MPP6_GPIO,		/* ??? */
 29	MPP7_GPIO,		/* ??? */
 30	MPP8_UNUSED,		/* ??? */
 31	MPP9_GIGE,		/* GE_RXERR */
 32	MPP10_UNUSED,		/* ??? */
 33	MPP11_UNUSED,		/* ??? */
 34	MPP12_GIGE,		/* GE_TXD[4] */
 35	MPP13_GIGE,		/* GE_TXD[5] */
 36	MPP14_GIGE,		/* GE_TXD[6] */
 37	MPP15_GIGE,		/* GE_TXD[7] */
 38	MPP16_GIGE,		/* GE_RXD[4] */
 39	MPP17_GIGE,		/* GE_RXD[5] */
 40	MPP18_GIGE,		/* GE_RXD[6] */
 41	MPP19_GIGE,		/* GE_RXD[7] */
 42	0,
 43};
 44
 45/*
 46 * 8M NOR flash Device bus boot chip select
 47 */
 48#define WNR854T_NOR_BOOT_BASE	0xf4000000
 49#define WNR854T_NOR_BOOT_SIZE	SZ_8M
 50
 51static struct mtd_partition wnr854t_nor_flash_partitions[] = {
 52	{
 53		.name		= "kernel",
 54		.offset		= 0x00000000,
 55		.size		= 0x00100000,
 56	}, {
 57		.name		= "rootfs",
 58		.offset		= 0x00100000,
 59		.size		= 0x00660000,
 60	}, {
 61		.name		= "uboot",
 62		.offset		= 0x00760000,
 63		.size		= 0x00040000,
 64	},
 65};
 66
 67static struct physmap_flash_data wnr854t_nor_flash_data = {
 68	.width		= 2,
 69	.parts		= wnr854t_nor_flash_partitions,
 70	.nr_parts	= ARRAY_SIZE(wnr854t_nor_flash_partitions),
 71};
 72
 73static struct resource wnr854t_nor_flash_resource = {
 74	.flags		= IORESOURCE_MEM,
 75	.start		= WNR854T_NOR_BOOT_BASE,
 76	.end		= WNR854T_NOR_BOOT_BASE + WNR854T_NOR_BOOT_SIZE - 1,
 77};
 78
 79static struct platform_device wnr854t_nor_flash = {
 80	.name			= "physmap-flash",
 81	.id			= 0,
 82	.dev		= {
 83		.platform_data	= &wnr854t_nor_flash_data,
 84	},
 85	.num_resources		= 1,
 86	.resource		= &wnr854t_nor_flash_resource,
 87};
 88
 89static struct mv643xx_eth_platform_data wnr854t_eth_data = {
 90	.phy_addr	= MV643XX_ETH_PHY_NONE,
 91	.speed		= SPEED_1000,
 92	.duplex		= DUPLEX_FULL,
 93};
 94
 95static struct dsa_chip_data wnr854t_switch_chip_data = {
 96	.port_names[0] = "lan3",
 97	.port_names[1] = "lan4",
 98	.port_names[2] = "wan",
 99	.port_names[3] = "cpu",
100	.port_names[5] = "lan1",
101	.port_names[7] = "lan2",
102};
103
104static void __init wnr854t_init(void)
105{
106	/*
107	 * Setup basic Orion functions. Need to be called early.
108	 */
109	orion5x_init();
110
111	orion5x_mpp_conf(wnr854t_mpp_modes);
112
113	/*
114	 * Configure peripherals.
115	 */
116	orion5x_eth_init(&wnr854t_eth_data);
117	orion5x_eth_switch_init(&wnr854t_switch_chip_data);
118	orion5x_uart0_init();
119
120	mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
121				    ORION_MBUS_DEVBUS_BOOT_ATTR,
122				    WNR854T_NOR_BOOT_BASE,
123				    WNR854T_NOR_BOOT_SIZE);
124	platform_device_register(&wnr854t_nor_flash);
125}
126
127static int __init wnr854t_pci_map_irq(const struct pci_dev *dev, u8 slot,
128	u8 pin)
129{
130	int irq;
131
132	/*
133	 * Check for devices with hard-wired IRQs.
134	 */
135	irq = orion5x_pci_map_irq(dev, slot, pin);
136	if (irq != -1)
137		return irq;
138
139	/*
140	 * Mini-PCI slot.
141	 */
142	if (slot == 7)
143		return gpio_to_irq(4);
144
145	return -1;
146}
147
148static struct hw_pci wnr854t_pci __initdata = {
149	.nr_controllers	= 2,
150	.setup		= orion5x_pci_sys_setup,
151	.scan		= orion5x_pci_sys_scan_bus,
152	.map_irq	= wnr854t_pci_map_irq,
153};
154
155static int __init wnr854t_pci_init(void)
156{
157	if (machine_is_wnr854t())
158		pci_common_init(&wnr854t_pci);
159
160	return 0;
161}
162subsys_initcall(wnr854t_pci_init);
163
164MACHINE_START(WNR854T, "Netgear WNR854T")
165	/* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
166	.atag_offset	= 0x100,
167	.nr_irqs	= ORION5X_NR_IRQS,
168	.init_machine	= wnr854t_init,
169	.map_io		= orion5x_map_io,
170	.init_early	= orion5x_init_early,
171	.init_irq	= orion5x_init_irq,
172	.init_time	= orion5x_timer_init,
173	.fixup		= tag_fixup_mem32,
174	.restart	= orion5x_restart,
175MACHINE_END
v5.14.15
  1/*
  2 * arch/arm/mach-orion5x/wnr854t-setup.c
  3 *
  4 * This file is licensed under the terms of the GNU General Public
  5 * License version 2.  This program is licensed "as is" without any
  6 * warranty of any kind, whether express or implied.
  7 */
  8#include <linux/gpio.h>
  9#include <linux/kernel.h>
 10#include <linux/init.h>
 11#include <linux/platform_device.h>
 12#include <linux/pci.h>
 13#include <linux/irq.h>
 14#include <linux/delay.h>
 15#include <linux/mtd/physmap.h>
 16#include <linux/mv643xx_eth.h>
 17#include <linux/ethtool.h>
 18#include <linux/platform_data/dsa.h>
 19#include <asm/mach-types.h>
 20#include <asm/mach/arch.h>
 21#include <asm/mach/pci.h>
 22#include "orion5x.h"
 23#include "common.h"
 24#include "mpp.h"
 25
 26static unsigned int wnr854t_mpp_modes[] __initdata = {
 27	MPP0_GPIO,		/* Power LED green (0=on) */
 28	MPP1_GPIO,		/* Reset Button (0=off) */
 29	MPP2_GPIO,		/* Power LED blink (0=off) */
 30	MPP3_GPIO,		/* WAN Status LED amber (0=off) */
 31	MPP4_GPIO,		/* PCI int */
 32	MPP5_GPIO,		/* ??? */
 33	MPP6_GPIO,		/* ??? */
 34	MPP7_GPIO,		/* ??? */
 35	MPP8_UNUSED,		/* ??? */
 36	MPP9_GIGE,		/* GE_RXERR */
 37	MPP10_UNUSED,		/* ??? */
 38	MPP11_UNUSED,		/* ??? */
 39	MPP12_GIGE,		/* GE_TXD[4] */
 40	MPP13_GIGE,		/* GE_TXD[5] */
 41	MPP14_GIGE,		/* GE_TXD[6] */
 42	MPP15_GIGE,		/* GE_TXD[7] */
 43	MPP16_GIGE,		/* GE_RXD[4] */
 44	MPP17_GIGE,		/* GE_RXD[5] */
 45	MPP18_GIGE,		/* GE_RXD[6] */
 46	MPP19_GIGE,		/* GE_RXD[7] */
 47	0,
 48};
 49
 50/*
 51 * 8M NOR flash Device bus boot chip select
 52 */
 53#define WNR854T_NOR_BOOT_BASE	0xf4000000
 54#define WNR854T_NOR_BOOT_SIZE	SZ_8M
 55
 56static struct mtd_partition wnr854t_nor_flash_partitions[] = {
 57	{
 58		.name		= "kernel",
 59		.offset		= 0x00000000,
 60		.size		= 0x00100000,
 61	}, {
 62		.name		= "rootfs",
 63		.offset		= 0x00100000,
 64		.size		= 0x00660000,
 65	}, {
 66		.name		= "uboot",
 67		.offset		= 0x00760000,
 68		.size		= 0x00040000,
 69	},
 70};
 71
 72static struct physmap_flash_data wnr854t_nor_flash_data = {
 73	.width		= 2,
 74	.parts		= wnr854t_nor_flash_partitions,
 75	.nr_parts	= ARRAY_SIZE(wnr854t_nor_flash_partitions),
 76};
 77
 78static struct resource wnr854t_nor_flash_resource = {
 79	.flags		= IORESOURCE_MEM,
 80	.start		= WNR854T_NOR_BOOT_BASE,
 81	.end		= WNR854T_NOR_BOOT_BASE + WNR854T_NOR_BOOT_SIZE - 1,
 82};
 83
 84static struct platform_device wnr854t_nor_flash = {
 85	.name			= "physmap-flash",
 86	.id			= 0,
 87	.dev		= {
 88		.platform_data	= &wnr854t_nor_flash_data,
 89	},
 90	.num_resources		= 1,
 91	.resource		= &wnr854t_nor_flash_resource,
 92};
 93
 94static struct mv643xx_eth_platform_data wnr854t_eth_data = {
 95	.phy_addr	= MV643XX_ETH_PHY_NONE,
 96	.speed		= SPEED_1000,
 97	.duplex		= DUPLEX_FULL,
 98};
 99
100static struct dsa_chip_data wnr854t_switch_chip_data = {
101	.port_names[0] = "lan3",
102	.port_names[1] = "lan4",
103	.port_names[2] = "wan",
104	.port_names[3] = "cpu",
105	.port_names[5] = "lan1",
106	.port_names[7] = "lan2",
107};
108
109static void __init wnr854t_init(void)
110{
111	/*
112	 * Setup basic Orion functions. Need to be called early.
113	 */
114	orion5x_init();
115
116	orion5x_mpp_conf(wnr854t_mpp_modes);
117
118	/*
119	 * Configure peripherals.
120	 */
121	orion5x_eth_init(&wnr854t_eth_data);
122	orion5x_eth_switch_init(&wnr854t_switch_chip_data);
123	orion5x_uart0_init();
124
125	mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
126				    ORION_MBUS_DEVBUS_BOOT_ATTR,
127				    WNR854T_NOR_BOOT_BASE,
128				    WNR854T_NOR_BOOT_SIZE);
129	platform_device_register(&wnr854t_nor_flash);
130}
131
132static int __init wnr854t_pci_map_irq(const struct pci_dev *dev, u8 slot,
133	u8 pin)
134{
135	int irq;
136
137	/*
138	 * Check for devices with hard-wired IRQs.
139	 */
140	irq = orion5x_pci_map_irq(dev, slot, pin);
141	if (irq != -1)
142		return irq;
143
144	/*
145	 * Mini-PCI slot.
146	 */
147	if (slot == 7)
148		return gpio_to_irq(4);
149
150	return -1;
151}
152
153static struct hw_pci wnr854t_pci __initdata = {
154	.nr_controllers	= 2,
155	.setup		= orion5x_pci_sys_setup,
156	.scan		= orion5x_pci_sys_scan_bus,
157	.map_irq	= wnr854t_pci_map_irq,
158};
159
160static int __init wnr854t_pci_init(void)
161{
162	if (machine_is_wnr854t())
163		pci_common_init(&wnr854t_pci);
164
165	return 0;
166}
167subsys_initcall(wnr854t_pci_init);
168
169MACHINE_START(WNR854T, "Netgear WNR854T")
170	/* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
171	.atag_offset	= 0x100,
172	.nr_irqs	= ORION5X_NR_IRQS,
173	.init_machine	= wnr854t_init,
174	.map_io		= orion5x_map_io,
175	.init_early	= orion5x_init_early,
176	.init_irq	= orion5x_init_irq,
177	.init_time	= orion5x_timer_init,
178	.fixup		= tag_fixup_mem32,
179	.restart	= orion5x_restart,
180MACHINE_END