setup.c 3.9 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 <sound/sh_dac_audio.h>
  17. #include <asm/hd64461.h>
  18. #include <asm/io.h>
  19. #include <mach/hp6xx.h>
  20. #include <cpu/dac.h>
  21. #define SCPCR 0xa4000116
  22. #define SCPDR 0xa4000136
  23. /* CF Slot */
  24. static struct resource cf_ide_resources[] = {
  25. [0] = {
  26. .start = 0x15000000 + 0x1f0,
  27. .end = 0x15000000 + 0x1f0 + 0x08 - 0x01,
  28. .flags = IORESOURCE_MEM,
  29. },
  30. [1] = {
  31. .start = 0x15000000 + 0x1fe,
  32. .end = 0x15000000 + 0x1fe + 0x01,
  33. .flags = IORESOURCE_MEM,
  34. },
  35. [2] = {
  36. .start = 77,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. };
  40. static struct platform_device cf_ide_device = {
  41. .name = "pata_platform",
  42. .id = -1,
  43. .num_resources = ARRAY_SIZE(cf_ide_resources),
  44. .resource = cf_ide_resources,
  45. };
  46. static struct platform_device jornadakbd_device = {
  47. .name = "jornada680_kbd",
  48. .id = -1,
  49. };
  50. static void dac_audio_start(struct dac_audio_pdata *pdata)
  51. {
  52. u16 v;
  53. u8 v8;
  54. /* HP Jornada 680/690 speaker on */
  55. v = inw(HD64461_GPADR);
  56. v &= ~HD64461_GPADR_SPEAKER;
  57. outw(v, HD64461_GPADR);
  58. /* HP Palmtop 620lx/660lx speaker on */
  59. v8 = inb(PKDR);
  60. v8 &= ~PKDR_SPEAKER;
  61. outb(v8, PKDR);
  62. sh_dac_enable(pdata->channel);
  63. }
  64. static void dac_audio_stop(struct dac_audio_pdata *pdata)
  65. {
  66. u16 v;
  67. u8 v8;
  68. /* HP Jornada 680/690 speaker off */
  69. v = inw(HD64461_GPADR);
  70. v |= HD64461_GPADR_SPEAKER;
  71. outw(v, HD64461_GPADR);
  72. /* HP Palmtop 620lx/660lx speaker off */
  73. v8 = inb(PKDR);
  74. v8 |= PKDR_SPEAKER;
  75. outb(v8, PKDR);
  76. sh_dac_output(0, pdata->channel);
  77. sh_dac_disable(pdata->channel);
  78. }
  79. static struct dac_audio_pdata dac_audio_platform_data = {
  80. .buffer_size = 64000,
  81. .channel = 1,
  82. .start = dac_audio_start,
  83. .stop = dac_audio_stop,
  84. };
  85. static struct platform_device dac_audio_device = {
  86. .name = "dac_audio",
  87. .id = -1,
  88. .dev = {
  89. .platform_data = &dac_audio_platform_data,
  90. }
  91. };
  92. static struct platform_device *hp6xx_devices[] __initdata = {
  93. &cf_ide_device,
  94. &jornadakbd_device,
  95. &dac_audio_device,
  96. };
  97. static void __init hp6xx_init_irq(void)
  98. {
  99. /* Gets touchscreen and powerbutton IRQ working */
  100. plat_irq_setup_pins(IRQ_MODE_IRQ);
  101. }
  102. static int __init hp6xx_devices_setup(void)
  103. {
  104. return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
  105. }
  106. static void __init hp6xx_setup(char **cmdline_p)
  107. {
  108. u8 v8;
  109. u16 v;
  110. v = inw(HD64461_STBCR);
  111. v |= HD64461_STBCR_SURTST | HD64461_STBCR_SIRST |
  112. HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST |
  113. HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST |
  114. HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
  115. HD64461_STBCR_SAFECKE_IST;
  116. #ifndef CONFIG_HD64461_ENABLER
  117. v |= HD64461_STBCR_SPC1ST;
  118. #endif
  119. outw(v, HD64461_STBCR);
  120. v = inw(HD64461_GPADR);
  121. v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
  122. outw(v, HD64461_GPADR);
  123. outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);
  124. #ifndef CONFIG_HD64461_ENABLER
  125. outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
  126. #endif
  127. sh_dac_output(0, DAC_SPEAKER_VOLUME);
  128. sh_dac_disable(DAC_SPEAKER_VOLUME);
  129. v8 = ctrl_inb(DACR);
  130. v8 &= ~DACR_DAE;
  131. ctrl_outb(v8,DACR);
  132. v8 = ctrl_inb(SCPDR);
  133. v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
  134. v8 &= ~SCPDR_TS_SCAN_ENABLE;
  135. ctrl_outb(v8, SCPDR);
  136. v = ctrl_inw(SCPCR);
  137. v &= ~SCPCR_TS_MASK;
  138. v |= SCPCR_TS_ENABLE;
  139. ctrl_outw(v, SCPCR);
  140. }
  141. device_initcall(hp6xx_devices_setup);
  142. static struct sh_machine_vector mv_hp6xx __initmv = {
  143. .mv_name = "hp6xx",
  144. .mv_setup = hp6xx_setup,
  145. /* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */
  146. .mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM + 6,
  147. /* Enable IRQ0 -> IRQ3 in IRQ_MODE */
  148. .mv_init_irq = hp6xx_init_irq,
  149. };