setup.c 3.8 KB

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