Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 * linux/arch/sh/boards/hp6xx/setup.c
  3 *
  4 * Copyright (C) 2002 Andriy Skulysh
  5 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer_e1@hotmail.com>
  6 *
  7 * May be copied or modified under the terms of the GNU General Public
  8 * License.  See linux/COPYING for more information.
  9 *
 10 * Setup code for HP620/HP660/HP680/HP690 (internal peripherials only)
 11 */
 12#include <linux/types.h>
 13#include <linux/init.h>
 14#include <linux/platform_device.h>
 15#include <linux/irq.h>
 16#include <linux/sh_intc.h>
 17#include <sound/sh_dac_audio.h>
 18#include <asm/hd64461.h>
 19#include <asm/io.h>
 20#include <mach/hp6xx.h>
 21#include <cpu/dac.h>
 22
 23#define	SCPCR	0xa4000116
 24#define	SCPDR	0xa4000136
 25
 26/* CF Slot */
 27static struct resource cf_ide_resources[] = {
 28	[0] = {
 29		.start = 0x15000000 + 0x1f0,
 30		.end   = 0x15000000 + 0x1f0 + 0x08 - 0x01,
 31		.flags = IORESOURCE_MEM,
 32	},
 33	[1] = {
 34		.start = 0x15000000 + 0x1fe,
 35		.end   = 0x15000000 + 0x1fe + 0x01,
 36		.flags = IORESOURCE_MEM,
 37	},
 38	[2] = {
 39		.start = evt2irq(0xba0),
 40		.flags = IORESOURCE_IRQ,
 41	},
 42};
 43
 44static struct platform_device cf_ide_device = {
 45	.name		=  "pata_platform",
 46	.id		=  -1,
 47	.num_resources	= ARRAY_SIZE(cf_ide_resources),
 48	.resource	= cf_ide_resources,
 49};
 50
 51static struct platform_device jornadakbd_device = {
 52	.name		= "jornada680_kbd",
 53	.id		= -1,
 54};
 55
 56static void dac_audio_start(struct dac_audio_pdata *pdata)
 57{
 58	u16 v;
 59	u8 v8;
 60
 61	/* HP Jornada 680/690 speaker on */
 62	v = inw(HD64461_GPADR);
 63	v &= ~HD64461_GPADR_SPEAKER;
 64	outw(v, HD64461_GPADR);
 65
 66	/* HP Palmtop 620lx/660lx speaker on */
 67	v8 = inb(PKDR);
 68	v8 &= ~PKDR_SPEAKER;
 69	outb(v8, PKDR);
 70
 71	sh_dac_enable(pdata->channel);
 72}
 73
 74static void dac_audio_stop(struct dac_audio_pdata *pdata)
 75{
 76	u16 v;
 77	u8 v8;
 78
 79	/* HP Jornada 680/690 speaker off */
 80	v = inw(HD64461_GPADR);
 81	v |= HD64461_GPADR_SPEAKER;
 82	outw(v, HD64461_GPADR);
 83
 84	/* HP Palmtop 620lx/660lx speaker off */
 85	v8 = inb(PKDR);
 86	v8 |= PKDR_SPEAKER;
 87	outb(v8, PKDR);
 88
 89	sh_dac_output(0, pdata->channel);
 90	sh_dac_disable(pdata->channel);
 91}
 92
 93static struct dac_audio_pdata dac_audio_platform_data = {
 94	.buffer_size		= 64000,
 95	.channel		= 1,
 96	.start			= dac_audio_start,
 97	.stop			= dac_audio_stop,
 98};
 99
100static struct platform_device dac_audio_device = {
101	.name		= "dac_audio",
102	.id		= -1,
103	.dev		= {
104		.platform_data	= &dac_audio_platform_data,
105	}
106
107};
108
109static struct platform_device *hp6xx_devices[] __initdata = {
110	&cf_ide_device,
111	&jornadakbd_device,
112	&dac_audio_device,
113};
114
115static void __init hp6xx_init_irq(void)
116{
117	/* Gets touchscreen and powerbutton IRQ working */
118	plat_irq_setup_pins(IRQ_MODE_IRQ);
119}
120
121static int __init hp6xx_devices_setup(void)
122{
123	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
124}
125
126static void __init hp6xx_setup(char **cmdline_p)
127{
128	u8 v8;
129	u16 v;
130
131	v = inw(HD64461_STBCR);
132	v |=	HD64461_STBCR_SURTST | HD64461_STBCR_SIRST	|
133		HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST	|
134		HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST	|
135		HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
136		HD64461_STBCR_SAFECKE_IST;
137#ifndef CONFIG_HD64461_ENABLER
138	v |= HD64461_STBCR_SPC1ST;
139#endif
140	outw(v, HD64461_STBCR);
141	v = inw(HD64461_GPADR);
142	v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
143	outw(v, HD64461_GPADR);
144
145	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);
146
147#ifndef CONFIG_HD64461_ENABLER
148	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
149#endif
150
151	sh_dac_output(0, DAC_SPEAKER_VOLUME);
152	sh_dac_disable(DAC_SPEAKER_VOLUME);
153	v8 = __raw_readb(DACR);
154	v8 &= ~DACR_DAE;
155	__raw_writeb(v8,DACR);
156
157	v8 = __raw_readb(SCPDR);
158	v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
159	v8 &= ~SCPDR_TS_SCAN_ENABLE;
160	__raw_writeb(v8, SCPDR);
161
162	v = __raw_readw(SCPCR);
163	v &= ~SCPCR_TS_MASK;
164	v |= SCPCR_TS_ENABLE;
165	__raw_writew(v, SCPCR);
166}
167device_initcall(hp6xx_devices_setup);
168
169static struct sh_machine_vector mv_hp6xx __initmv = {
170	.mv_name = "hp6xx",
171	.mv_setup = hp6xx_setup,
172	/* Enable IRQ0 -> IRQ3 in IRQ_MODE */
173	.mv_init_irq = hp6xx_init_irq,
174};
v5.9
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * linux/arch/sh/boards/hp6xx/setup.c
  4 *
  5 * Copyright (C) 2002 Andriy Skulysh
  6 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer_e1@hotmail.com>
 
 
 
  7 *
  8 * Setup code for HP620/HP660/HP680/HP690 (internal peripherials only)
  9 */
 10#include <linux/types.h>
 11#include <linux/init.h>
 12#include <linux/platform_device.h>
 13#include <linux/irq.h>
 14#include <linux/sh_intc.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>
 20
 21#define	SCPCR	0xa4000116
 22#define	SCPDR	0xa4000136
 23
 24/* 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 = evt2irq(0xba0),
 38		.flags = IORESOURCE_IRQ,
 39	},
 40};
 41
 42static 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};
 48
 49static struct platform_device jornadakbd_device = {
 50	.name		= "jornada680_kbd",
 51	.id		= -1,
 52};
 53
 54static void dac_audio_start(struct dac_audio_pdata *pdata)
 55{
 56	u16 v;
 57	u8 v8;
 58
 59	/* HP Jornada 680/690 speaker on */
 60	v = inw(HD64461_GPADR);
 61	v &= ~HD64461_GPADR_SPEAKER;
 62	outw(v, HD64461_GPADR);
 63
 64	/* HP Palmtop 620lx/660lx speaker on */
 65	v8 = inb(PKDR);
 66	v8 &= ~PKDR_SPEAKER;
 67	outb(v8, PKDR);
 68
 69	sh_dac_enable(pdata->channel);
 70}
 71
 72static void dac_audio_stop(struct dac_audio_pdata *pdata)
 73{
 74	u16 v;
 75	u8 v8;
 76
 77	/* HP Jornada 680/690 speaker off */
 78	v = inw(HD64461_GPADR);
 79	v |= HD64461_GPADR_SPEAKER;
 80	outw(v, HD64461_GPADR);
 81
 82	/* HP Palmtop 620lx/660lx speaker off */
 83	v8 = inb(PKDR);
 84	v8 |= PKDR_SPEAKER;
 85	outb(v8, PKDR);
 86
 87	sh_dac_output(0, pdata->channel);
 88	sh_dac_disable(pdata->channel);
 89}
 90
 91static 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};
 97
 98static struct platform_device dac_audio_device = {
 99	.name		= "dac_audio",
100	.id		= -1,
101	.dev		= {
102		.platform_data	= &dac_audio_platform_data,
103	}
104
105};
106
107static struct platform_device *hp6xx_devices[] __initdata = {
108	&cf_ide_device,
109	&jornadakbd_device,
110	&dac_audio_device,
111};
112
113static void __init hp6xx_init_irq(void)
114{
115	/* Gets touchscreen and powerbutton IRQ working */
116	plat_irq_setup_pins(IRQ_MODE_IRQ);
117}
118
119static int __init hp6xx_devices_setup(void)
120{
121	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
122}
123
124static void __init hp6xx_setup(char **cmdline_p)
125{
126	u8 v8;
127	u16 v;
128
129	v = inw(HD64461_STBCR);
130	v |=	HD64461_STBCR_SURTST | HD64461_STBCR_SIRST	|
131		HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST	|
132		HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST	|
133		HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
134		HD64461_STBCR_SAFECKE_IST;
135#ifndef CONFIG_HD64461_ENABLER
136	v |= HD64461_STBCR_SPC1ST;
137#endif
138	outw(v, HD64461_STBCR);
139	v = inw(HD64461_GPADR);
140	v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
141	outw(v, HD64461_GPADR);
142
143	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);
144
145#ifndef CONFIG_HD64461_ENABLER
146	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
147#endif
148
149	sh_dac_output(0, DAC_SPEAKER_VOLUME);
150	sh_dac_disable(DAC_SPEAKER_VOLUME);
151	v8 = __raw_readb(DACR);
152	v8 &= ~DACR_DAE;
153	__raw_writeb(v8,DACR);
154
155	v8 = __raw_readb(SCPDR);
156	v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
157	v8 &= ~SCPDR_TS_SCAN_ENABLE;
158	__raw_writeb(v8, SCPDR);
159
160	v = __raw_readw(SCPCR);
161	v &= ~SCPCR_TS_MASK;
162	v |= SCPCR_TS_ENABLE;
163	__raw_writew(v, SCPCR);
164}
165device_initcall(hp6xx_devices_setup);
166
167static struct sh_machine_vector mv_hp6xx __initmv = {
168	.mv_name = "hp6xx",
169	.mv_setup = hp6xx_setup,
170	/* Enable IRQ0 -> IRQ3 in IRQ_MODE */
171	.mv_init_irq = hp6xx_init_irq,
172};