Path: blob/master/arch/sh/drivers/superhyway/ops-sh4-202.c
15125 views
/*1* arch/sh/drivers/superhyway/ops-sh4-202.c2*3* SuperHyway bus support for SH4-2024*5* Copyright (C) 2005 Paul Mundt6*7* This file is subject to the terms and conditions of the GNU8* General Public License. See the file "COPYING" in the main9* directory of this archive for more details.10*/11#include <linux/kernel.h>12#include <linux/init.h>13#include <linux/superhyway.h>14#include <linux/string.h>15#include <asm/addrspace.h>16#include <asm/io.h>1718#define PHYS_EMI_CBLOCK P4SEGADDR(0x1ec00000)19#define PHYS_EMI_DBLOCK P4SEGADDR(0x08000000)20#define PHYS_FEMI_CBLOCK P4SEGADDR(0x1f800000)21#define PHYS_FEMI_DBLOCK P4SEGADDR(0x00000000)2223#define PHYS_EPBR_BLOCK P4SEGADDR(0x1de00000)24#define PHYS_DMAC_BLOCK P4SEGADDR(0x1fa00000)25#define PHYS_PBR_BLOCK P4SEGADDR(0x1fc00000)2627static struct resource emi_resources[] = {28[0] = {29.start = PHYS_EMI_CBLOCK,30.end = PHYS_EMI_CBLOCK + 0x00300000 - 1,31.flags = IORESOURCE_MEM,32},33[1] = {34.start = PHYS_EMI_DBLOCK,35.end = PHYS_EMI_DBLOCK + 0x08000000 - 1,36.flags = IORESOURCE_MEM,37},38};3940static struct superhyway_device emi_device = {41.name = "emi",42.num_resources = ARRAY_SIZE(emi_resources),43.resource = emi_resources,44};4546static struct resource femi_resources[] = {47[0] = {48.start = PHYS_FEMI_CBLOCK,49.end = PHYS_FEMI_CBLOCK + 0x00100000 - 1,50.flags = IORESOURCE_MEM,51},52[1] = {53.start = PHYS_FEMI_DBLOCK,54.end = PHYS_FEMI_DBLOCK + 0x08000000 - 1,55.flags = IORESOURCE_MEM,56},57};5859static struct superhyway_device femi_device = {60.name = "femi",61.num_resources = ARRAY_SIZE(femi_resources),62.resource = femi_resources,63};6465static struct resource epbr_resources[] = {66[0] = {67.start = P4SEGADDR(0x1e7ffff8),68.end = P4SEGADDR(0x1e7ffff8 + (sizeof(u32) * 2) - 1),69.flags = IORESOURCE_MEM,70},71[1] = {72.start = PHYS_EPBR_BLOCK,73.end = PHYS_EPBR_BLOCK + 0x00a00000 - 1,74.flags = IORESOURCE_MEM,75},76};7778static struct superhyway_device epbr_device = {79.name = "epbr",80.num_resources = ARRAY_SIZE(epbr_resources),81.resource = epbr_resources,82};8384static struct resource dmac_resource = {85.start = PHYS_DMAC_BLOCK,86.end = PHYS_DMAC_BLOCK + 0x00100000 - 1,87.flags = IORESOURCE_MEM,88};8990static struct superhyway_device dmac_device = {91.name = "dmac",92.num_resources = 1,93.resource = &dmac_resource,94};9596static struct resource pbr_resources[] = {97[0] = {98.start = P4SEGADDR(0x1ffffff8),99.end = P4SEGADDR(0x1ffffff8 + (sizeof(u32) * 2) - 1),100.flags = IORESOURCE_MEM,101},102[1] = {103.start = PHYS_PBR_BLOCK,104.end = PHYS_PBR_BLOCK + 0x00400000 - (sizeof(u32) * 2) - 1,105.flags = IORESOURCE_MEM,106},107};108109static struct superhyway_device pbr_device = {110.name = "pbr",111.num_resources = ARRAY_SIZE(pbr_resources),112.resource = pbr_resources,113};114115static struct superhyway_device *sh4202_devices[] __initdata = {116&emi_device, &femi_device, &epbr_device, &dmac_device, &pbr_device,117};118119static int sh4202_read_vcr(unsigned long base, struct superhyway_vcr_info *vcr)120{121u32 vcrh, vcrl;122u64 tmp;123124/*125* XXX: Even though the SH4-202 Evaluation Device documentation126* indicates that VCRL is mapped first with VCRH at a + 0x04127* offset, the opposite seems to be true.128*129* Some modules (PBR and ePBR for instance) also appear to have130* VCRL/VCRH flipped in the documentation, but on the SH4-202131* itself it appears that these are all consistently mapped with132* VCRH preceding VCRL.133*134* Do not trust the documentation, for it is evil.135*/136vcrh = __raw_readl(base);137vcrl = __raw_readl(base + sizeof(u32));138139tmp = ((u64)vcrh << 32) | vcrl;140memcpy(vcr, &tmp, sizeof(u64));141142return 0;143}144145static int sh4202_write_vcr(unsigned long base, struct superhyway_vcr_info vcr)146{147u64 tmp = *(u64 *)&vcr;148149__raw_writel((tmp >> 32) & 0xffffffff, base);150__raw_writel(tmp & 0xffffffff, base + sizeof(u32));151152return 0;153}154155static struct superhyway_ops sh4202_superhyway_ops = {156.read_vcr = sh4202_read_vcr,157.write_vcr = sh4202_write_vcr,158};159160struct superhyway_bus superhyway_channels[] = {161{ &sh4202_superhyway_ops, },162{ 0, },163};164165int __init superhyway_scan_bus(struct superhyway_bus *bus)166{167return superhyway_add_devices(bus, sh4202_devices,168ARRAY_SIZE(sh4202_devices));169}170171172173