setup.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. #define SCPCR 0xa4000116
  23. #define SCPDR 0xa4000136
  24. /* CF Slot */
  25. static 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. static struct platform_device cf_ide_device = {
  42. .name = "pata_platform",
  43. .id = -1,
  44. .num_resources = ARRAY_SIZE(cf_ide_resources),
  45. .resource = cf_ide_resources,
  46. };
  47. static struct platform_device jornadakbd_device = {
  48. .name = "jornada680_kbd",
  49. .id = -1,
  50. };
  51. static void dac_audio_start(struct dac_audio_pdata *pdata)
  52. {
  53. u16 v;
  54. u8 v8;
  55. /* HP Jornada 680/690 speaker on */
  56. v = inw(HD64461_GPADR);
  57. v &= ~HD64461_GPADR_SPEAKER;
  58. outw(v, HD64461_GPADR);
  59. /* HP Palmtop 620lx/660lx speaker on */
  60. v8 = inb(PKDR);
  61. v8 &= ~PKDR_SPEAKER;
  62. outb(v8, PKDR);
  63. sh_dac_enable(pdata->channel);
  64. }
  65. static void dac_audio_stop(struct dac_audio_pdata *pdata)
  66. {
  67. u16 v;
  68. u8 v8;
  69. /* HP Jornada 680/690 speaker off */
  70. v = inw(HD64461_GPADR);
  71. v |= HD64461_GPADR_SPEAKER;
  72. outw(v, HD64461_GPADR);
  73. /* HP Palmtop 620lx/660lx speaker off */
  74. v8 = inb(PKDR);
  75. v8 |= PKDR_SPEAKER;
  76. outb(v8, PKDR);
  77. sh_dac_output(0, pdata->channel);
  78. sh_dac_disable(pdata->channel);
  79. }
  80. static struct dac_audio_pdata dac_audio_platform_data = {
  81. .buffer_size = 64000,
  82. .channel = 1,
  83. .start = dac_audio_start,
  84. .stop = dac_audio_stop,
  85. };
  86. static struct platform_device dac_audio_device = {
  87. .name = "dac_audio",
  88. .id = -1,
  89. .dev = {
  90. .platform_data = &dac_audio_platform_data,
  91. }
  92. };
  93. static struct platform_device *hp6xx_devices[] __initdata = {
  94. &cf_ide_device,
  95. &jornadakbd_device,
  96. &dac_audio_device,
  97. };
  98. static void __init hp6xx_init_irq(void)
  99. {
  100. /* Gets touchscreen and powerbutton IRQ working */
  101. plat_irq_setup_pins(IRQ_MODE_IRQ);
  102. }
  103. static int __init hp6xx_devices_setup(void)
  104. {
  105. return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
  106. }
  107. static void __init hp6xx_setup(char **cmdline_p)
  108. {
  109. u8 v8;
  110. u16 v;
  111. v = inw(HD64461_STBCR);
  112. v |= HD64461_STBCR_SURTST | HD64461_STBCR_SIRST |
  113. HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST |
  114. HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST |
  115. HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
  116. HD64461_STBCR_SAFECKE_IST;
  117. #ifndef CONFIG_HD64461_ENABLER
  118. v |= HD64461_STBCR_SPC1ST;
  119. #endif
  120. outw(v, HD64461_STBCR);
  121. v = inw(HD64461_GPADR);
  122. v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
  123. outw(v, HD64461_GPADR);
  124. outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);
  125. #ifndef CONFIG_HD64461_ENABLER
  126. outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
  127. #endif
  128. sh_dac_output(0, DAC_SPEAKER_VOLUME);
  129. sh_dac_disable(DAC_SPEAKER_VOLUME);
  130. v8 = __raw_readb(DACR);
  131. v8 &= ~DACR_DAE;
  132. __raw_writeb(v8,DACR);
  133. v8 = __raw_readb(SCPDR);
  134. v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
  135. v8 &= ~SCPDR_TS_SCAN_ENABLE;
  136. __raw_writeb(v8, SCPDR);
  137. v = __raw_readw(SCPCR);
  138. v &= ~SCPCR_TS_MASK;
  139. v |= SCPCR_TS_ENABLE;
  140. __raw_writew(v, SCPCR);
  141. }
  142. device_initcall(hp6xx_devices_setup);
  143. static struct sh_machine_vector mv_hp6xx __initmv = {
  144. .mv_name = "hp6xx",
  145. .mv_setup = hp6xx_setup,
  146. /* Enable IRQ0 -> IRQ3 in IRQ_MODE */
  147. .mv_init_irq = hp6xx_init_irq,
  148. };