Path: blob/master/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
17498 views
/*1* SH7786 Setup2*3* Copyright (C) 2009 - 2010 Renesas Solutions Corp.4* Kuninori Morimoto <[email protected]>5* Paul Mundt <[email protected]>6*7* Based on SH7785 Setup8*9* Copyright (C) 2007 Paul Mundt10*11* This file is subject to the terms and conditions of the GNU General Public12* License. See the file "COPYING" in the main directory of this archive13* for more details.14*/15#include <linux/platform_device.h>16#include <linux/init.h>17#include <linux/serial.h>18#include <linux/serial_sci.h>19#include <linux/io.h>20#include <linux/mm.h>21#include <linux/dma-mapping.h>22#include <linux/sh_timer.h>23#include <linux/sh_dma.h>24#include <linux/sh_intc.h>25#include <cpu/dma-register.h>26#include <asm/mmzone.h>2728static struct plat_sci_port scif0_platform_data = {29.mapbase = 0xffea0000,30.flags = UPF_BOOT_AUTOCONF,31.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,32.scbrr_algo_id = SCBRR_ALGO_1,33.type = PORT_SCIF,34.irqs = { 40, 41, 43, 42 },35};3637static struct platform_device scif0_device = {38.name = "sh-sci",39.id = 0,40.dev = {41.platform_data = &scif0_platform_data,42},43};4445/*46* The rest of these all have multiplexed IRQs47*/48static struct plat_sci_port scif1_platform_data = {49.mapbase = 0xffeb0000,50.flags = UPF_BOOT_AUTOCONF,51.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,52.scbrr_algo_id = SCBRR_ALGO_1,53.type = PORT_SCIF,54.irqs = { 44, 44, 44, 44 },55};5657static struct platform_device scif1_device = {58.name = "sh-sci",59.id = 1,60.dev = {61.platform_data = &scif1_platform_data,62},63};6465static struct plat_sci_port scif2_platform_data = {66.mapbase = 0xffec0000,67.flags = UPF_BOOT_AUTOCONF,68.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,69.scbrr_algo_id = SCBRR_ALGO_1,70.type = PORT_SCIF,71.irqs = { 50, 50, 50, 50 },72};7374static struct platform_device scif2_device = {75.name = "sh-sci",76.id = 2,77.dev = {78.platform_data = &scif2_platform_data,79},80};8182static struct plat_sci_port scif3_platform_data = {83.mapbase = 0xffed0000,84.flags = UPF_BOOT_AUTOCONF,85.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,86.scbrr_algo_id = SCBRR_ALGO_1,87.type = PORT_SCIF,88.irqs = { 51, 51, 51, 51 },89};9091static struct platform_device scif3_device = {92.name = "sh-sci",93.id = 3,94.dev = {95.platform_data = &scif3_platform_data,96},97};9899static struct plat_sci_port scif4_platform_data = {100.mapbase = 0xffee0000,101.flags = UPF_BOOT_AUTOCONF,102.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,103.scbrr_algo_id = SCBRR_ALGO_1,104.type = PORT_SCIF,105.irqs = { 52, 52, 52, 52 },106};107108static struct platform_device scif4_device = {109.name = "sh-sci",110.id = 4,111.dev = {112.platform_data = &scif4_platform_data,113},114};115116static struct plat_sci_port scif5_platform_data = {117.mapbase = 0xffef0000,118.flags = UPF_BOOT_AUTOCONF,119.scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,120.scbrr_algo_id = SCBRR_ALGO_1,121.type = PORT_SCIF,122.irqs = { 53, 53, 53, 53 },123};124125static struct platform_device scif5_device = {126.name = "sh-sci",127.id = 5,128.dev = {129.platform_data = &scif5_platform_data,130},131};132133static struct sh_timer_config tmu0_platform_data = {134.channel_offset = 0x04,135.timer_bit = 0,136.clockevent_rating = 200,137};138139static struct resource tmu0_resources[] = {140[0] = {141.start = 0xffd80008,142.end = 0xffd80013,143.flags = IORESOURCE_MEM,144},145[1] = {146.start = 16,147.flags = IORESOURCE_IRQ,148},149};150151static struct platform_device tmu0_device = {152.name = "sh_tmu",153.id = 0,154.dev = {155.platform_data = &tmu0_platform_data,156},157.resource = tmu0_resources,158.num_resources = ARRAY_SIZE(tmu0_resources),159};160161static struct sh_timer_config tmu1_platform_data = {162.channel_offset = 0x10,163.timer_bit = 1,164.clocksource_rating = 200,165};166167static struct resource tmu1_resources[] = {168[0] = {169.start = 0xffd80014,170.end = 0xffd8001f,171.flags = IORESOURCE_MEM,172},173[1] = {174.start = 17,175.flags = IORESOURCE_IRQ,176},177};178179static struct platform_device tmu1_device = {180.name = "sh_tmu",181.id = 1,182.dev = {183.platform_data = &tmu1_platform_data,184},185.resource = tmu1_resources,186.num_resources = ARRAY_SIZE(tmu1_resources),187};188189static struct sh_timer_config tmu2_platform_data = {190.channel_offset = 0x1c,191.timer_bit = 2,192};193194static struct resource tmu2_resources[] = {195[0] = {196.start = 0xffd80020,197.end = 0xffd8002f,198.flags = IORESOURCE_MEM,199},200[1] = {201.start = 18,202.flags = IORESOURCE_IRQ,203},204};205206static struct platform_device tmu2_device = {207.name = "sh_tmu",208.id = 2,209.dev = {210.platform_data = &tmu2_platform_data,211},212.resource = tmu2_resources,213.num_resources = ARRAY_SIZE(tmu2_resources),214};215216static struct sh_timer_config tmu3_platform_data = {217.channel_offset = 0x04,218.timer_bit = 0,219};220221static struct resource tmu3_resources[] = {222[0] = {223.start = 0xffda0008,224.end = 0xffda0013,225.flags = IORESOURCE_MEM,226},227[1] = {228.start = 20,229.flags = IORESOURCE_IRQ,230},231};232233static struct platform_device tmu3_device = {234.name = "sh_tmu",235.id = 3,236.dev = {237.platform_data = &tmu3_platform_data,238},239.resource = tmu3_resources,240.num_resources = ARRAY_SIZE(tmu3_resources),241};242243static struct sh_timer_config tmu4_platform_data = {244.channel_offset = 0x10,245.timer_bit = 1,246};247248static struct resource tmu4_resources[] = {249[0] = {250.start = 0xffda0014,251.end = 0xffda001f,252.flags = IORESOURCE_MEM,253},254[1] = {255.start = 21,256.flags = IORESOURCE_IRQ,257},258};259260static struct platform_device tmu4_device = {261.name = "sh_tmu",262.id = 4,263.dev = {264.platform_data = &tmu4_platform_data,265},266.resource = tmu4_resources,267.num_resources = ARRAY_SIZE(tmu4_resources),268};269270static struct sh_timer_config tmu5_platform_data = {271.channel_offset = 0x1c,272.timer_bit = 2,273};274275static struct resource tmu5_resources[] = {276[0] = {277.start = 0xffda0020,278.end = 0xffda002b,279.flags = IORESOURCE_MEM,280},281[1] = {282.start = 22,283.flags = IORESOURCE_IRQ,284},285};286287static struct platform_device tmu5_device = {288.name = "sh_tmu",289.id = 5,290.dev = {291.platform_data = &tmu5_platform_data,292},293.resource = tmu5_resources,294.num_resources = ARRAY_SIZE(tmu5_resources),295};296297static struct sh_timer_config tmu6_platform_data = {298.channel_offset = 0x04,299.timer_bit = 0,300};301302static struct resource tmu6_resources[] = {303[0] = {304.start = 0xffdc0008,305.end = 0xffdc0013,306.flags = IORESOURCE_MEM,307},308[1] = {309.start = 45,310.flags = IORESOURCE_IRQ,311},312};313314static struct platform_device tmu6_device = {315.name = "sh_tmu",316.id = 6,317.dev = {318.platform_data = &tmu6_platform_data,319},320.resource = tmu6_resources,321.num_resources = ARRAY_SIZE(tmu6_resources),322};323324static struct sh_timer_config tmu7_platform_data = {325.channel_offset = 0x10,326.timer_bit = 1,327};328329static struct resource tmu7_resources[] = {330[0] = {331.start = 0xffdc0014,332.end = 0xffdc001f,333.flags = IORESOURCE_MEM,334},335[1] = {336.start = 45,337.flags = IORESOURCE_IRQ,338},339};340341static struct platform_device tmu7_device = {342.name = "sh_tmu",343.id = 7,344.dev = {345.platform_data = &tmu7_platform_data,346},347.resource = tmu7_resources,348.num_resources = ARRAY_SIZE(tmu7_resources),349};350351static struct sh_timer_config tmu8_platform_data = {352.channel_offset = 0x1c,353.timer_bit = 2,354};355356static struct resource tmu8_resources[] = {357[0] = {358.start = 0xffdc0020,359.end = 0xffdc002b,360.flags = IORESOURCE_MEM,361},362[1] = {363.start = 45,364.flags = IORESOURCE_IRQ,365},366};367368static struct platform_device tmu8_device = {369.name = "sh_tmu",370.id = 8,371.dev = {372.platform_data = &tmu8_platform_data,373},374.resource = tmu8_resources,375.num_resources = ARRAY_SIZE(tmu8_resources),376};377378static struct sh_timer_config tmu9_platform_data = {379.channel_offset = 0x04,380.timer_bit = 0,381};382383static struct resource tmu9_resources[] = {384[0] = {385.start = 0xffde0008,386.end = 0xffde0013,387.flags = IORESOURCE_MEM,388},389[1] = {390.start = 46,391.flags = IORESOURCE_IRQ,392},393};394395static struct platform_device tmu9_device = {396.name = "sh_tmu",397.id = 9,398.dev = {399.platform_data = &tmu9_platform_data,400},401.resource = tmu9_resources,402.num_resources = ARRAY_SIZE(tmu9_resources),403};404405static struct sh_timer_config tmu10_platform_data = {406.channel_offset = 0x10,407.timer_bit = 1,408};409410static struct resource tmu10_resources[] = {411[0] = {412.start = 0xffde0014,413.end = 0xffde001f,414.flags = IORESOURCE_MEM,415},416[1] = {417.start = 46,418.flags = IORESOURCE_IRQ,419},420};421422static struct platform_device tmu10_device = {423.name = "sh_tmu",424.id = 10,425.dev = {426.platform_data = &tmu10_platform_data,427},428.resource = tmu10_resources,429.num_resources = ARRAY_SIZE(tmu10_resources),430};431432static struct sh_timer_config tmu11_platform_data = {433.channel_offset = 0x1c,434.timer_bit = 2,435};436437static struct resource tmu11_resources[] = {438[0] = {439.start = 0xffde0020,440.end = 0xffde002b,441.flags = IORESOURCE_MEM,442},443[1] = {444.start = 46,445.flags = IORESOURCE_IRQ,446},447};448449static struct platform_device tmu11_device = {450.name = "sh_tmu",451.id = 11,452.dev = {453.platform_data = &tmu11_platform_data,454},455.resource = tmu11_resources,456.num_resources = ARRAY_SIZE(tmu11_resources),457};458459static const struct sh_dmae_channel dmac0_channels[] = {460{461.offset = 0,462.dmars = 0,463.dmars_bit = 0,464}, {465.offset = 0x10,466.dmars = 0,467.dmars_bit = 8,468}, {469.offset = 0x20,470.dmars = 4,471.dmars_bit = 0,472}, {473.offset = 0x30,474.dmars = 4,475.dmars_bit = 8,476}, {477.offset = 0x50,478.dmars = 8,479.dmars_bit = 0,480}, {481.offset = 0x60,482.dmars = 8,483.dmars_bit = 8,484}485};486487static const unsigned int ts_shift[] = TS_SHIFT;488489static struct sh_dmae_pdata dma0_platform_data = {490.channel = dmac0_channels,491.channel_num = ARRAY_SIZE(dmac0_channels),492.ts_low_shift = CHCR_TS_LOW_SHIFT,493.ts_low_mask = CHCR_TS_LOW_MASK,494.ts_high_shift = CHCR_TS_HIGH_SHIFT,495.ts_high_mask = CHCR_TS_HIGH_MASK,496.ts_shift = ts_shift,497.ts_shift_num = ARRAY_SIZE(ts_shift),498.dmaor_init = DMAOR_INIT,499};500501/* Resource order important! */502static struct resource dmac0_resources[] = {503{504/* Channel registers and DMAOR */505.start = 0xfe008020,506.end = 0xfe00808f,507.flags = IORESOURCE_MEM,508}, {509/* DMARSx */510.start = 0xfe009000,511.end = 0xfe00900b,512.flags = IORESOURCE_MEM,513}, {514/* DMA error IRQ */515.start = evt2irq(0x5c0),516.end = evt2irq(0x5c0),517.flags = IORESOURCE_IRQ,518}, {519/* IRQ for channels 0-5 */520.start = evt2irq(0x500),521.end = evt2irq(0x5a0),522.flags = IORESOURCE_IRQ,523},524};525526static struct platform_device dma0_device = {527.name = "sh-dma-engine",528.id = 0,529.resource = dmac0_resources,530.num_resources = ARRAY_SIZE(dmac0_resources),531.dev = {532.platform_data = &dma0_platform_data,533},534};535536#define USB_EHCI_START 0xffe70000537#define USB_OHCI_START 0xffe70400538539static struct resource usb_ehci_resources[] = {540[0] = {541.start = USB_EHCI_START,542.end = USB_EHCI_START + 0x3ff,543.flags = IORESOURCE_MEM,544},545[1] = {546.start = 77,547.end = 77,548.flags = IORESOURCE_IRQ,549},550};551552static struct platform_device usb_ehci_device = {553.name = "sh_ehci",554.id = -1,555.dev = {556.dma_mask = &usb_ehci_device.dev.coherent_dma_mask,557.coherent_dma_mask = DMA_BIT_MASK(32),558},559.num_resources = ARRAY_SIZE(usb_ehci_resources),560.resource = usb_ehci_resources,561};562563static struct resource usb_ohci_resources[] = {564[0] = {565.start = USB_OHCI_START,566.end = USB_OHCI_START + 0x3ff,567.flags = IORESOURCE_MEM,568},569[1] = {570.start = 77,571.end = 77,572.flags = IORESOURCE_IRQ,573},574};575576static struct platform_device usb_ohci_device = {577.name = "sh_ohci",578.id = -1,579.dev = {580.dma_mask = &usb_ohci_device.dev.coherent_dma_mask,581.coherent_dma_mask = DMA_BIT_MASK(32),582},583.num_resources = ARRAY_SIZE(usb_ohci_resources),584.resource = usb_ohci_resources,585};586587static struct platform_device *sh7786_early_devices[] __initdata = {588&scif0_device,589&scif1_device,590&scif2_device,591&scif3_device,592&scif4_device,593&scif5_device,594&tmu0_device,595&tmu1_device,596&tmu2_device,597&tmu3_device,598&tmu4_device,599&tmu5_device,600&tmu6_device,601&tmu7_device,602&tmu8_device,603&tmu9_device,604&tmu10_device,605&tmu11_device,606};607608static struct platform_device *sh7786_devices[] __initdata = {609&dma0_device,610&usb_ehci_device,611&usb_ohci_device,612};613614/*615* Please call this function if your platform board616* use external clock for USB617* */618#define USBCTL0 0xffe70858619#define CLOCK_MODE_MASK 0xffffff7f620#define EXT_CLOCK_MODE 0x00000080621622void __init sh7786_usb_use_exclock(void)623{624u32 val = __raw_readl(USBCTL0) & CLOCK_MODE_MASK;625__raw_writel(val | EXT_CLOCK_MODE, USBCTL0);626}627628#define USBINITREG1 0xffe70094629#define USBINITREG2 0xffe7009c630#define USBINITVAL1 0x00ff0040631#define USBINITVAL2 0x00000001632633#define USBPCTL1 0xffe70804634#define USBST 0xffe70808635#define PHY_ENB 0x00000001636#define PLL_ENB 0x00000002637#define PHY_RST 0x00000004638#define ACT_PLL_STATUS 0xc0000000639640static void __init sh7786_usb_setup(void)641{642int i = 1000000;643644/*645* USB initial settings646*647* The following settings are necessary648* for using the USB modules.649*650* see "USB Initial Settings" for detail651*/652__raw_writel(USBINITVAL1, USBINITREG1);653__raw_writel(USBINITVAL2, USBINITREG2);654655/*656* Set the PHY and PLL enable bit657*/658__raw_writel(PHY_ENB | PLL_ENB, USBPCTL1);659while (i--) {660if (ACT_PLL_STATUS == (__raw_readl(USBST) & ACT_PLL_STATUS)) {661/* Set the PHY RST bit */662__raw_writel(PHY_ENB | PLL_ENB | PHY_RST, USBPCTL1);663printk(KERN_INFO "sh7786 usb setup done\n");664break;665}666cpu_relax();667}668}669670enum {671UNUSED = 0,672673/* interrupt sources */674IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,675IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,676IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,677IRL0_HHLL, IRL0_HHLH, IRL0_HHHL,678679IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,680IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,681IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,682IRL4_HHLL, IRL4_HHLH, IRL4_HHHL,683684IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,685WDT,686TMU0_0, TMU0_1, TMU0_2, TMU0_3,687TMU1_0, TMU1_1, TMU1_2,688DMAC0_0, DMAC0_1, DMAC0_2, DMAC0_3, DMAC0_4, DMAC0_5, DMAC0_6,689HUDI1, HUDI0,690DMAC1_0, DMAC1_1, DMAC1_2, DMAC1_3,691HPB_0, HPB_1, HPB_2,692SCIF0_0, SCIF0_1, SCIF0_2, SCIF0_3,693SCIF1,694TMU2, TMU3,695SCIF2, SCIF3, SCIF4, SCIF5,696Eth_0, Eth_1,697PCIeC0_0, PCIeC0_1, PCIeC0_2,698PCIeC1_0, PCIeC1_1, PCIeC1_2,699USB,700I2C0, I2C1,701DU,702SSI0, SSI1, SSI2, SSI3,703PCIeC2_0, PCIeC2_1, PCIeC2_2,704HAC0, HAC1,705FLCTL,706HSPI,707GPIO0, GPIO1,708Thermal,709INTICI0, INTICI1, INTICI2, INTICI3,710INTICI4, INTICI5, INTICI6, INTICI7,711712/* Muxed sub-events */713TXI1, BRI1, RXI1, ERI1,714};715716static struct intc_vect sh7786_vectors[] __initdata = {717INTC_VECT(WDT, 0x3e0),718INTC_VECT(TMU0_0, 0x400), INTC_VECT(TMU0_1, 0x420),719INTC_VECT(TMU0_2, 0x440), INTC_VECT(TMU0_3, 0x460),720INTC_VECT(TMU1_0, 0x480), INTC_VECT(TMU1_1, 0x4a0),721INTC_VECT(TMU1_2, 0x4c0),722INTC_VECT(DMAC0_0, 0x500), INTC_VECT(DMAC0_1, 0x520),723INTC_VECT(DMAC0_2, 0x540), INTC_VECT(DMAC0_3, 0x560),724INTC_VECT(DMAC0_4, 0x580), INTC_VECT(DMAC0_5, 0x5a0),725INTC_VECT(DMAC0_6, 0x5c0),726INTC_VECT(HUDI1, 0x5e0), INTC_VECT(HUDI0, 0x600),727INTC_VECT(DMAC1_0, 0x620), INTC_VECT(DMAC1_1, 0x640),728INTC_VECT(DMAC1_2, 0x660), INTC_VECT(DMAC1_3, 0x680),729INTC_VECT(HPB_0, 0x6a0), INTC_VECT(HPB_1, 0x6c0),730INTC_VECT(HPB_2, 0x6e0),731INTC_VECT(SCIF0_0, 0x700), INTC_VECT(SCIF0_1, 0x720),732INTC_VECT(SCIF0_2, 0x740), INTC_VECT(SCIF0_3, 0x760),733INTC_VECT(SCIF1, 0x780),734INTC_VECT(TMU2, 0x7a0), INTC_VECT(TMU3, 0x7c0),735INTC_VECT(SCIF2, 0x840), INTC_VECT(SCIF3, 0x860),736INTC_VECT(SCIF4, 0x880), INTC_VECT(SCIF5, 0x8a0),737INTC_VECT(Eth_0, 0x8c0), INTC_VECT(Eth_1, 0x8e0),738INTC_VECT(PCIeC0_0, 0xae0), INTC_VECT(PCIeC0_1, 0xb00),739INTC_VECT(PCIeC0_2, 0xb20),740INTC_VECT(PCIeC1_0, 0xb40), INTC_VECT(PCIeC1_1, 0xb60),741INTC_VECT(PCIeC1_2, 0xb80),742INTC_VECT(USB, 0xba0),743INTC_VECT(I2C0, 0xcc0), INTC_VECT(I2C1, 0xce0),744INTC_VECT(DU, 0xd00),745INTC_VECT(SSI0, 0xd20), INTC_VECT(SSI1, 0xd40),746INTC_VECT(SSI2, 0xd60), INTC_VECT(SSI3, 0xd80),747INTC_VECT(PCIeC2_0, 0xda0), INTC_VECT(PCIeC2_1, 0xdc0),748INTC_VECT(PCIeC2_2, 0xde0),749INTC_VECT(HAC0, 0xe00), INTC_VECT(HAC1, 0xe20),750INTC_VECT(FLCTL, 0xe40),751INTC_VECT(HSPI, 0xe80),752INTC_VECT(GPIO0, 0xea0), INTC_VECT(GPIO1, 0xec0),753INTC_VECT(Thermal, 0xee0),754INTC_VECT(INTICI0, 0xf00), INTC_VECT(INTICI1, 0xf20),755INTC_VECT(INTICI2, 0xf40), INTC_VECT(INTICI3, 0xf60),756INTC_VECT(INTICI4, 0xf80), INTC_VECT(INTICI5, 0xfa0),757INTC_VECT(INTICI6, 0xfc0), INTC_VECT(INTICI7, 0xfe0),758};759760#define CnINTMSK0 0xfe410030761#define CnINTMSK1 0xfe410040762#define CnINTMSKCLR0 0xfe410050763#define CnINTMSKCLR1 0xfe410060764#define CnINT2MSKR0 0xfe410a20765#define CnINT2MSKR1 0xfe410a24766#define CnINT2MSKR2 0xfe410a28767#define CnINT2MSKR3 0xfe410a2c768#define CnINT2MSKCR0 0xfe410a30769#define CnINT2MSKCR1 0xfe410a34770#define CnINT2MSKCR2 0xfe410a38771#define CnINT2MSKCR3 0xfe410a3c772#define INTMSK2 0xfe410068773#define INTMSKCLR2 0xfe41006c774775#define INTDISTCR0 0xfe4100b0776#define INTDISTCR1 0xfe4100b4777#define INT2DISTCR0 0xfe410900778#define INT2DISTCR1 0xfe410904779#define INT2DISTCR2 0xfe410908780#define INT2DISTCR3 0xfe41090c781782static struct intc_mask_reg sh7786_mask_registers[] __initdata = {783{ CnINTMSK0, CnINTMSKCLR0, 32,784{ IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 },785INTC_SMP_BALANCING(INTDISTCR0) },786{ INTMSK2, INTMSKCLR2, 32,787{ IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,788IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,789IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,790IRL0_HHLL, IRL0_HHLH, IRL0_HHHL, 0,791IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,792IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,793IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,794IRL4_HHLL, IRL4_HHLH, IRL4_HHHL, 0, } },795{ CnINT2MSKR0, CnINT2MSKCR0 , 32,796{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,7970, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, WDT },798INTC_SMP_BALANCING(INT2DISTCR0) },799{ CnINT2MSKR1, CnINT2MSKCR1, 32,800{ TMU0_0, TMU0_1, TMU0_2, TMU0_3, TMU1_0, TMU1_1, TMU1_2, 0,801DMAC0_0, DMAC0_1, DMAC0_2, DMAC0_3, DMAC0_4, DMAC0_5, DMAC0_6,802HUDI1, HUDI0,803DMAC1_0, DMAC1_1, DMAC1_2, DMAC1_3,804HPB_0, HPB_1, HPB_2,805SCIF0_0, SCIF0_1, SCIF0_2, SCIF0_3,806SCIF1,807TMU2, TMU3, 0, }, INTC_SMP_BALANCING(INT2DISTCR1) },808{ CnINT2MSKR2, CnINT2MSKCR2, 32,809{ 0, 0, SCIF2, SCIF3, SCIF4, SCIF5,810Eth_0, Eth_1,8110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,812PCIeC0_0, PCIeC0_1, PCIeC0_2,813PCIeC1_0, PCIeC1_1, PCIeC1_2,814USB, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR2) },815{ CnINT2MSKR3, CnINT2MSKCR3, 32,816{ 0, 0, 0, 0, 0, 0,817I2C0, I2C1,818DU, SSI0, SSI1, SSI2, SSI3,819PCIeC2_0, PCIeC2_1, PCIeC2_2,820HAC0, HAC1,821FLCTL, 0,822HSPI, GPIO0, GPIO1, Thermal,8230, 0, 0, 0, 0, 0, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR3) },824};825826static struct intc_prio_reg sh7786_prio_registers[] __initdata = {827{ 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,828IRQ4, IRQ5, IRQ6, IRQ7 } },829{ 0xfe410800, 0, 32, 8, /* INT2PRI0 */ { 0, 0, 0, WDT } },830{ 0xfe410804, 0, 32, 8, /* INT2PRI1 */ { TMU0_0, TMU0_1,831TMU0_2, TMU0_3 } },832{ 0xfe410808, 0, 32, 8, /* INT2PRI2 */ { TMU1_0, TMU1_1,833TMU1_2, 0 } },834{ 0xfe41080c, 0, 32, 8, /* INT2PRI3 */ { DMAC0_0, DMAC0_1,835DMAC0_2, DMAC0_3 } },836{ 0xfe410810, 0, 32, 8, /* INT2PRI4 */ { DMAC0_4, DMAC0_5,837DMAC0_6, HUDI1 } },838{ 0xfe410814, 0, 32, 8, /* INT2PRI5 */ { HUDI0, DMAC1_0,839DMAC1_1, DMAC1_2 } },840{ 0xfe410818, 0, 32, 8, /* INT2PRI6 */ { DMAC1_3, HPB_0,841HPB_1, HPB_2 } },842{ 0xfe41081c, 0, 32, 8, /* INT2PRI7 */ { SCIF0_0, SCIF0_1,843SCIF0_2, SCIF0_3 } },844{ 0xfe410820, 0, 32, 8, /* INT2PRI8 */ { SCIF1, TMU2, TMU3, 0 } },845{ 0xfe410824, 0, 32, 8, /* INT2PRI9 */ { 0, 0, SCIF2, SCIF3 } },846{ 0xfe410828, 0, 32, 8, /* INT2PRI10 */ { SCIF4, SCIF5,847Eth_0, Eth_1 } },848{ 0xfe41082c, 0, 32, 8, /* INT2PRI11 */ { 0, 0, 0, 0 } },849{ 0xfe410830, 0, 32, 8, /* INT2PRI12 */ { 0, 0, 0, 0 } },850{ 0xfe410834, 0, 32, 8, /* INT2PRI13 */ { 0, 0, 0, 0 } },851{ 0xfe410838, 0, 32, 8, /* INT2PRI14 */ { 0, 0, 0, PCIeC0_0 } },852{ 0xfe41083c, 0, 32, 8, /* INT2PRI15 */ { PCIeC0_1, PCIeC0_2,853PCIeC1_0, PCIeC1_1 } },854{ 0xfe410840, 0, 32, 8, /* INT2PRI16 */ { PCIeC1_2, USB, 0, 0 } },855{ 0xfe410844, 0, 32, 8, /* INT2PRI17 */ { 0, 0, 0, 0 } },856{ 0xfe410848, 0, 32, 8, /* INT2PRI18 */ { 0, 0, I2C0, I2C1 } },857{ 0xfe41084c, 0, 32, 8, /* INT2PRI19 */ { DU, SSI0, SSI1, SSI2 } },858{ 0xfe410850, 0, 32, 8, /* INT2PRI20 */ { SSI3, PCIeC2_0,859PCIeC2_1, PCIeC2_2 } },860{ 0xfe410854, 0, 32, 8, /* INT2PRI21 */ { HAC0, HAC1, FLCTL, 0 } },861{ 0xfe410858, 0, 32, 8, /* INT2PRI22 */ { HSPI, GPIO0,862GPIO1, Thermal } },863{ 0xfe41085c, 0, 32, 8, /* INT2PRI23 */ { 0, 0, 0, 0 } },864{ 0xfe410860, 0, 32, 8, /* INT2PRI24 */ { 0, 0, 0, 0 } },865{ 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */866{ INTICI7, INTICI6, INTICI5, INTICI4,867INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 2) },868};869870static struct intc_subgroup sh7786_subgroups[] __initdata = {871{ 0xfe410c20, 32, SCIF1,872{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,8730, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TXI1, BRI1, RXI1, ERI1 } },874};875876static struct intc_desc sh7786_intc_desc __initdata = {877.name = "sh7786",878.hw = {879.vectors = sh7786_vectors,880.nr_vectors = ARRAY_SIZE(sh7786_vectors),881.mask_regs = sh7786_mask_registers,882.nr_mask_regs = ARRAY_SIZE(sh7786_mask_registers),883.subgroups = sh7786_subgroups,884.nr_subgroups = ARRAY_SIZE(sh7786_subgroups),885.prio_regs = sh7786_prio_registers,886.nr_prio_regs = ARRAY_SIZE(sh7786_prio_registers),887},888};889890/* Support for external interrupt pins in IRQ mode */891static struct intc_vect vectors_irq0123[] __initdata = {892INTC_VECT(IRQ0, 0x200), INTC_VECT(IRQ1, 0x240),893INTC_VECT(IRQ2, 0x280), INTC_VECT(IRQ3, 0x2c0),894};895896static struct intc_vect vectors_irq4567[] __initdata = {897INTC_VECT(IRQ4, 0x300), INTC_VECT(IRQ5, 0x340),898INTC_VECT(IRQ6, 0x380), INTC_VECT(IRQ7, 0x3c0),899};900901static struct intc_sense_reg sh7786_sense_registers[] __initdata = {902{ 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,903IRQ4, IRQ5, IRQ6, IRQ7 } },904};905906static struct intc_mask_reg sh7786_ack_registers[] __initdata = {907{ 0xfe410024, 0, 32, /* INTREQ */908{ IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },909};910911static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7786-irq0123",912vectors_irq0123, NULL, sh7786_mask_registers,913sh7786_prio_registers, sh7786_sense_registers,914sh7786_ack_registers);915916static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7786-irq4567",917vectors_irq4567, NULL, sh7786_mask_registers,918sh7786_prio_registers, sh7786_sense_registers,919sh7786_ack_registers);920921/* External interrupt pins in IRL mode */922923static struct intc_vect vectors_irl0123[] __initdata = {924INTC_VECT(IRL0_LLLL, 0x200), INTC_VECT(IRL0_LLLH, 0x220),925INTC_VECT(IRL0_LLHL, 0x240), INTC_VECT(IRL0_LLHH, 0x260),926INTC_VECT(IRL0_LHLL, 0x280), INTC_VECT(IRL0_LHLH, 0x2a0),927INTC_VECT(IRL0_LHHL, 0x2c0), INTC_VECT(IRL0_LHHH, 0x2e0),928INTC_VECT(IRL0_HLLL, 0x300), INTC_VECT(IRL0_HLLH, 0x320),929INTC_VECT(IRL0_HLHL, 0x340), INTC_VECT(IRL0_HLHH, 0x360),930INTC_VECT(IRL0_HHLL, 0x380), INTC_VECT(IRL0_HHLH, 0x3a0),931INTC_VECT(IRL0_HHHL, 0x3c0),932};933934static struct intc_vect vectors_irl4567[] __initdata = {935INTC_VECT(IRL4_LLLL, 0x900), INTC_VECT(IRL4_LLLH, 0x920),936INTC_VECT(IRL4_LLHL, 0x940), INTC_VECT(IRL4_LLHH, 0x960),937INTC_VECT(IRL4_LHLL, 0x980), INTC_VECT(IRL4_LHLH, 0x9a0),938INTC_VECT(IRL4_LHHL, 0x9c0), INTC_VECT(IRL4_LHHH, 0x9e0),939INTC_VECT(IRL4_HLLL, 0xa00), INTC_VECT(IRL4_HLLH, 0xa20),940INTC_VECT(IRL4_HLHL, 0xa40), INTC_VECT(IRL4_HLHH, 0xa60),941INTC_VECT(IRL4_HHLL, 0xa80), INTC_VECT(IRL4_HHLH, 0xaa0),942INTC_VECT(IRL4_HHHL, 0xac0),943};944945static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7786-irl0123", vectors_irl0123,946NULL, sh7786_mask_registers, NULL, NULL);947948static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7786-irl4567", vectors_irl4567,949NULL, sh7786_mask_registers, NULL, NULL);950951#define INTC_ICR0 0xfe410000952#define INTC_INTMSK0 CnINTMSK0953#define INTC_INTMSK1 CnINTMSK1954#define INTC_INTMSK2 INTMSK2955#define INTC_INTMSKCLR1 CnINTMSKCLR1956#define INTC_INTMSKCLR2 INTMSKCLR2957958void __init plat_irq_setup(void)959{960/* disable IRQ3-0 + IRQ7-4 */961__raw_writel(0xff000000, INTC_INTMSK0);962963/* disable IRL3-0 + IRL7-4 */964__raw_writel(0xc0000000, INTC_INTMSK1);965__raw_writel(0xfffefffe, INTC_INTMSK2);966967/* select IRL mode for IRL3-0 + IRL7-4 */968__raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);969970register_intc_controller(&sh7786_intc_desc);971}972973void __init plat_irq_setup_pins(int mode)974{975switch (mode) {976case IRQ_MODE_IRQ7654:977/* select IRQ mode for IRL7-4 */978__raw_writel(__raw_readl(INTC_ICR0) | 0x00400000, INTC_ICR0);979register_intc_controller(&intc_desc_irq4567);980break;981case IRQ_MODE_IRQ3210:982/* select IRQ mode for IRL3-0 */983__raw_writel(__raw_readl(INTC_ICR0) | 0x00800000, INTC_ICR0);984register_intc_controller(&intc_desc_irq0123);985break;986case IRQ_MODE_IRL7654:987/* enable IRL7-4 but don't provide any masking */988__raw_writel(0x40000000, INTC_INTMSKCLR1);989__raw_writel(0x0000fffe, INTC_INTMSKCLR2);990break;991case IRQ_MODE_IRL3210:992/* enable IRL0-3 but don't provide any masking */993__raw_writel(0x80000000, INTC_INTMSKCLR1);994__raw_writel(0xfffe0000, INTC_INTMSKCLR2);995break;996case IRQ_MODE_IRL7654_MASK:997/* enable IRL7-4 and mask using cpu intc controller */998__raw_writel(0x40000000, INTC_INTMSKCLR1);999register_intc_controller(&intc_desc_irl4567);1000break;1001case IRQ_MODE_IRL3210_MASK:1002/* enable IRL0-3 and mask using cpu intc controller */1003__raw_writel(0x80000000, INTC_INTMSKCLR1);1004register_intc_controller(&intc_desc_irl0123);1005break;1006default:1007BUG();1008}1009}10101011void __init plat_mem_setup(void)1012{1013}10141015static int __init sh7786_devices_setup(void)1016{1017int ret, irq;10181019sh7786_usb_setup();10201021/*1022* De-mux SCIF1 IRQs if possible1023*/1024irq = intc_irq_lookup(sh7786_intc_desc.name, TXI1);1025if (irq > 0) {1026scif1_platform_data.irqs[SCIx_TXI_IRQ] = irq;1027scif1_platform_data.irqs[SCIx_ERI_IRQ] =1028intc_irq_lookup(sh7786_intc_desc.name, ERI1);1029scif1_platform_data.irqs[SCIx_BRI_IRQ] =1030intc_irq_lookup(sh7786_intc_desc.name, BRI1);1031scif1_platform_data.irqs[SCIx_RXI_IRQ] =1032intc_irq_lookup(sh7786_intc_desc.name, RXI1);1033}10341035ret = platform_add_devices(sh7786_early_devices,1036ARRAY_SIZE(sh7786_early_devices));1037if (unlikely(ret != 0))1038return ret;10391040return platform_add_devices(sh7786_devices,1041ARRAY_SIZE(sh7786_devices));1042}1043arch_initcall(sh7786_devices_setup);10441045void __init plat_early_device_setup(void)1046{1047early_platform_add_devices(sh7786_early_devices,1048ARRAY_SIZE(sh7786_early_devices));1049}105010511052