Path: blob/master/arch/m68k/platform/5307/nettel.c
10819 views
/***************************************************************************/12/*3* nettel.c -- startup code support for the NETtel boards4*5* Copyright (C) 2009, Greg Ungerer ([email protected])6*/78/***************************************************************************/910#include <linux/kernel.h>11#include <linux/param.h>12#include <linux/init.h>13#include <linux/io.h>14#include <linux/platform_device.h>15#include <asm/coldfire.h>16#include <asm/mcfsim.h>17#include <asm/nettel.h>1819/***************************************************************************/2021/*22* Define the IO and interrupt resources of the 2 SMC9196 interfaces.23*/24#define NETTEL_SMC0_ADDR 0x3060030025#define NETTEL_SMC0_IRQ 292627#define NETTEL_SMC1_ADDR 0x3060000028#define NETTEL_SMC1_IRQ 272930/*31* We need some access into the SMC9196 registers. Define those registers32* we will need here (including the smc91x.h doesn't seem to give us these33* in a simple form).34*/35#define SMC91xx_BANKSELECT 1436#define SMC91xx_BASEADDR 237#define SMC91xx_BASEMAC 43839/***************************************************************************/4041static struct resource nettel_smc91x_0_resources[] = {42{43.start = NETTEL_SMC0_ADDR,44.end = NETTEL_SMC0_ADDR + 0x20,45.flags = IORESOURCE_MEM,46},47{48.start = NETTEL_SMC0_IRQ,49.end = NETTEL_SMC0_IRQ,50.flags = IORESOURCE_IRQ,51},52};5354static struct resource nettel_smc91x_1_resources[] = {55{56.start = NETTEL_SMC1_ADDR,57.end = NETTEL_SMC1_ADDR + 0x20,58.flags = IORESOURCE_MEM,59},60{61.start = NETTEL_SMC1_IRQ,62.end = NETTEL_SMC1_IRQ,63.flags = IORESOURCE_IRQ,64},65};6667static struct platform_device nettel_smc91x[] = {68{69.name = "smc91x",70.id = 0,71.num_resources = ARRAY_SIZE(nettel_smc91x_0_resources),72.resource = nettel_smc91x_0_resources,73},74{75.name = "smc91x",76.id = 1,77.num_resources = ARRAY_SIZE(nettel_smc91x_1_resources),78.resource = nettel_smc91x_1_resources,79},80};8182static struct platform_device *nettel_devices[] __initdata = {83&nettel_smc91x[0],84&nettel_smc91x[1],85};8687/***************************************************************************/8889static u8 nettel_macdefault[] __initdata = {900x00, 0xd0, 0xcf, 0x00, 0x00, 0x01,91};9293/*94* Set flash contained MAC address into SMC9196 core. Make sure the flash95* MAC address is sane, and not an empty flash. If no good use the Moreton96* Bay default MAC address instead.97*/9899static void __init nettel_smc91x_setmac(unsigned int ioaddr, unsigned int flashaddr)100{101u16 *macp;102103macp = (u16 *) flashaddr;104if ((macp[0] == 0xffff) && (macp[1] == 0xffff) && (macp[2] == 0xffff))105macp = (u16 *) &nettel_macdefault[0];106107writew(1, NETTEL_SMC0_ADDR + SMC91xx_BANKSELECT);108writew(macp[0], ioaddr + SMC91xx_BASEMAC);109writew(macp[1], ioaddr + SMC91xx_BASEMAC + 2);110writew(macp[2], ioaddr + SMC91xx_BASEMAC + 4);111}112113/***************************************************************************/114115/*116* Re-map the address space of at least one of the SMC ethernet117* parts. Both parts power up decoding the same address, so we118* need to move one of them first, before doing anything else.119*/120121static void __init nettel_smc91x_init(void)122{123writew(0x00ec, MCF_MBAR + MCFSIM_PADDR);124mcf_setppdata(0, 0x0080);125writew(1, NETTEL_SMC0_ADDR + SMC91xx_BANKSELECT);126writew(0x0067, NETTEL_SMC0_ADDR + SMC91xx_BASEADDR);127mcf_setppdata(0x0080, 0);128129/* Set correct chip select timing for SMC9196 accesses */130writew(0x1180, MCF_MBAR + MCFSIM_CSCR3);131132/* Set the SMC interrupts to be auto-vectored */133mcf_autovector(NETTEL_SMC0_IRQ);134mcf_autovector(NETTEL_SMC1_IRQ);135136/* Set MAC addresses from flash for both interfaces */137nettel_smc91x_setmac(NETTEL_SMC0_ADDR, 0xf0006000);138nettel_smc91x_setmac(NETTEL_SMC1_ADDR, 0xf0006006);139}140141/***************************************************************************/142143static int __init init_nettel(void)144{145nettel_smc91x_init();146platform_add_devices(nettel_devices, ARRAY_SIZE(nettel_devices));147return 0;148}149150arch_initcall(init_nettel);151152/***************************************************************************/153154155