Path: blob/master/arch/sh/boards/mach-hp6xx/setup.c
15126 views
/*1* linux/arch/sh/boards/hp6xx/setup.c2*3* Copyright (C) 2002 Andriy Skulysh4* Copyright (C) 2007 Kristoffer Ericson <[email protected]>5*6* May be copied or modified under the terms of the GNU General Public7* License. See linux/COPYING for more information.8*9* Setup code for HP620/HP660/HP680/HP690 (internal peripherials only)10*/11#include <linux/types.h>12#include <linux/init.h>13#include <linux/platform_device.h>14#include <linux/irq.h>15#include <sound/sh_dac_audio.h>16#include <asm/hd64461.h>17#include <asm/io.h>18#include <mach/hp6xx.h>19#include <cpu/dac.h>2021#define SCPCR 0xa400011622#define SCPDR 0xa40001362324/* CF Slot */25static struct resource cf_ide_resources[] = {26[0] = {27.start = 0x15000000 + 0x1f0,28.end = 0x15000000 + 0x1f0 + 0x08 - 0x01,29.flags = IORESOURCE_MEM,30},31[1] = {32.start = 0x15000000 + 0x1fe,33.end = 0x15000000 + 0x1fe + 0x01,34.flags = IORESOURCE_MEM,35},36[2] = {37.start = 77,38.flags = IORESOURCE_IRQ,39},40};4142static struct platform_device cf_ide_device = {43.name = "pata_platform",44.id = -1,45.num_resources = ARRAY_SIZE(cf_ide_resources),46.resource = cf_ide_resources,47};4849static struct platform_device jornadakbd_device = {50.name = "jornada680_kbd",51.id = -1,52};5354static void dac_audio_start(struct dac_audio_pdata *pdata)55{56u16 v;57u8 v8;5859/* HP Jornada 680/690 speaker on */60v = inw(HD64461_GPADR);61v &= ~HD64461_GPADR_SPEAKER;62outw(v, HD64461_GPADR);6364/* HP Palmtop 620lx/660lx speaker on */65v8 = inb(PKDR);66v8 &= ~PKDR_SPEAKER;67outb(v8, PKDR);6869sh_dac_enable(pdata->channel);70}7172static void dac_audio_stop(struct dac_audio_pdata *pdata)73{74u16 v;75u8 v8;7677/* HP Jornada 680/690 speaker off */78v = inw(HD64461_GPADR);79v |= HD64461_GPADR_SPEAKER;80outw(v, HD64461_GPADR);8182/* HP Palmtop 620lx/660lx speaker off */83v8 = inb(PKDR);84v8 |= PKDR_SPEAKER;85outb(v8, PKDR);8687sh_dac_output(0, pdata->channel);88sh_dac_disable(pdata->channel);89}9091static struct dac_audio_pdata dac_audio_platform_data = {92.buffer_size = 64000,93.channel = 1,94.start = dac_audio_start,95.stop = dac_audio_stop,96};9798static struct platform_device dac_audio_device = {99.name = "dac_audio",100.id = -1,101.dev = {102.platform_data = &dac_audio_platform_data,103}104105};106107static struct platform_device *hp6xx_devices[] __initdata = {108&cf_ide_device,109&jornadakbd_device,110&dac_audio_device,111};112113static void __init hp6xx_init_irq(void)114{115/* Gets touchscreen and powerbutton IRQ working */116plat_irq_setup_pins(IRQ_MODE_IRQ);117}118119static int __init hp6xx_devices_setup(void)120{121return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));122}123124static void __init hp6xx_setup(char **cmdline_p)125{126u8 v8;127u16 v;128129v = inw(HD64461_STBCR);130v |= HD64461_STBCR_SURTST | HD64461_STBCR_SIRST |131HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST |132HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST |133HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|134HD64461_STBCR_SAFECKE_IST;135#ifndef CONFIG_HD64461_ENABLER136v |= HD64461_STBCR_SPC1ST;137#endif138outw(v, HD64461_STBCR);139v = inw(HD64461_GPADR);140v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;141outw(v, HD64461_GPADR);142143outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);144145#ifndef CONFIG_HD64461_ENABLER146outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);147#endif148149sh_dac_output(0, DAC_SPEAKER_VOLUME);150sh_dac_disable(DAC_SPEAKER_VOLUME);151v8 = __raw_readb(DACR);152v8 &= ~DACR_DAE;153__raw_writeb(v8,DACR);154155v8 = __raw_readb(SCPDR);156v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;157v8 &= ~SCPDR_TS_SCAN_ENABLE;158__raw_writeb(v8, SCPDR);159160v = __raw_readw(SCPCR);161v &= ~SCPCR_TS_MASK;162v |= SCPCR_TS_ENABLE;163__raw_writew(v, SCPCR);164}165device_initcall(hp6xx_devices_setup);166167static struct sh_machine_vector mv_hp6xx __initmv = {168.mv_name = "hp6xx",169.mv_setup = hp6xx_setup,170/* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */171.mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM + 6,172/* Enable IRQ0 -> IRQ3 in IRQ_MODE */173.mv_init_irq = hp6xx_init_irq,174};175176177