Author: wmb Date: Mon Oct 18 06:02:38 2010 New Revision: 1987 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1987
Log: Omnibus checkin of new and reorganized files for the OLPC ARM build, preparing for bringup.
Added: cpu/arm/marvell/utmiphy.fth cpu/arm/mmp2/boardgpio.fth cpu/arm/mmp2/boardtwsi.fth cpu/arm/mmp2/hwaddrs.fth cpu/arm/mmp2/uart.fth cpu/arm/olpc/1.75/boardgpio.fth cpu/arm/olpc/1.75/build/Makefile cpu/arm/olpc/1.75/devices.fth cpu/arm/olpc/1.75/dram-forth.fth cpu/arm/olpc/1.75/draminit.bth cpu/arm/olpc/1.75/lcdcfg.fth cpu/arm/olpc/1.75/sp.bth dev/usb2/hcd/uhci/pci.fth Modified: cpu/arm/mmp2/addrs.fth cpu/arm/mmp2/config.fth cpu/arm/mmp2/devices.fth cpu/arm/mmp2/dsi.fth cpu/arm/mmp2/fw.bth cpu/arm/mmp2/mfpr.fth cpu/arm/mmp2/timer.fth cpu/arm/mmp2/twsi.fth cpu/arm/olpc/1.75/xo-dram.fth dev/usb2/hcd/ehci/ehci.bth dev/usb2/hcd/ehci/ehci.fth dev/usb2/hcd/ehci/pci.fth dev/usb2/hcd/ehci/probe.fth dev/usb2/hcd/ehci/qhtd.fth dev/usb2/hcd/hcd.fth dev/usb2/hcd/uhci/uhci.bth dev/usb2/hcd/uhci/uhci.fth
Added: cpu/arm/marvell/utmiphy.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/marvell/utmiphy.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,48 @@ +\ See license at end of file +purpose: Init UTMI USB Phy in Marvell SoC + +h# d4207004 constant utmi-ctrl +h# d4207008 constant utmi-pll +h# d420700c constant utmi-tx +h# d4207010 constant utmi-rx +h# d4207014 constant utmi-ivref + +: regset ( mask adr -- ) tuck l@ or swap l! ; +: regclr ( mask adr -- ) tuck l@ swap invert and swap l! ; + +: wait-cal ( spins -- ) + 0 do + utmi-pll rl@ h# 0080.0000 and if unloop exit then + loop + ." PLL calibrate timeout" cr +; +: init-usb-phy ( -- ) + \ Turn on the USB PHY power + h# 1010.0000 utmi-ctrl regset \ INPKT_DELAY_SOF, PU_REF + h# 2 utmi-ctrl regset \ PLL_PWR_UP + h# 1 utmi-ctrl regset \ PWR_UP + + \ Configure the PLLs + h# 7e03.ffff utmi-pll regclr \ PLLCALI12, PLLVDD18, PLLVDD12, KVCO, ICP, FBDIV, REFDIV, + h# 7e01.aeeb utmi-pll regset \ 3 3 3 3 2 ee b + + h# 00df.c000 utmi-tx regclr \ TXVDD12, CK60_PHSEL, IMPCAL_VTH + h# 00c9.4000 utmi-tx regset \ 3 4 5 + + h# 0001.80f0 utmi-rx regclr \ REG_SQ_LENGTH, RX_SQ_THRESH + h# 0001.000a utmi-rx regset \ 2 a + + d# 10000 wait-cal + + d# 200 us + h# 0020.0000 utmi-pll regset \ VCOCAL_START + d# 40 us + h# 0020.0000 utmi-pll regclr + + d# 200 us + h# 0000.1000 utmi-tx regset \ REG_RCAL_START + d# 40 us + h# 0000.1000 utmi-tx regclr + + d# 1000 wait-cal +;
Modified: cpu/arm/mmp2/addrs.fth ============================================================================== --- cpu/arm/mmp2/addrs.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/addrs.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -38,15 +38,3 @@ d# 12 to pageshift h# 10.0000 constant /section h# 4000 constant /page-table - -\ Defined by MMP2 hardware -h# d401.9000 constant gpio-base -h# d405.1024 constant acgr-pa -h# d401.5000 constant clock-unit-pa -h# d405.0000 constant main-pmu-pa -h# d428.2800 constant pmua-pa \ Application processor PMU register base -h# d420.b800 constant dsi1-pa \ 4-lane controller -h# d420.ba00 constant dsi2-pa \ 3-lane controller -h# d420.b000 constant lcd-pa -h# d401.4000 constant timer-pa -
Added: cpu/arm/mmp2/boardgpio.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/boardgpio.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,218 @@ +purpose: Board-specific setup details - pin assigments, etc. + +: set-camera-domain-voltage + aib-unlock + h# d401e80c l@ 4 or ( n ) \ Set 1.8V selector bit in AIB_GPIO2_IO + aib-unlock + h# d401e80c l! +; + +: set-gpio-directions ( -- ) + 3 h# 38 clock-unit-pa + l! \ Enable clocks in GPIO clock reset register + + h# 000e.0000 gpio-base h# 0c + l! \ Bits 19, 18, 17 + h# 0704.2000 gpio-base h# 10 + l! \ Bits 58,57,56,50 and 45 +\ h# 03ec.3e00 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:73 + h# 03ec.3200 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:76 and 73 (leave 74 and 75 as input) + + h# 0200.3c00 gpio-base h# 20 + l! \ Turn off LEDS (3c00) and turn on 5V (0200.0000) +; + +create mfpr-table + 1 af, \ GPIO_00 - KP_MKIN[0] + 1 af, \ GPIO_01 - KP_MKOUT[0] + 1 af, \ GPIO_02 - KP_MKIN[1] + 1 af, \ GPIO_03 - KP_MKOUT[1] + 1 af, \ GPIO_04 - KP_MKIN[2] + 1 af, \ GPIO_05 - KP_MKOUT[2] + no-update, \ GPIO_06 - Not used + no-update, \ GPIO_07 - Not used + no-update, \ GPIO_08 - Not used + no-update, \ GPIO_09 - Not used + no-update, \ GPIO_10 - Not used + no-update, \ GPIO_11 - Not used + no-update, \ GPIO_12 - Not used + no-update, \ GPIO_13 - Not used + no-update, \ GPIO_14 - Not used + no-update, \ GPIO_15 - Not used + no-update, \ GPIO_16 - Not used + 0 af, \ GPIO_17 - BB_GPIO1 (use as GPIO out) + 0 af, \ GPIO_18 - BB_GPIO2 (use as GPIO out) + 0 af, \ GPIO_19 - BB_GPIO3 (use as GPIO out) + 0 af, \ GPIO_20 - ISP_INT (use as GPIO in) + 0 af, \ GPIO_21 - WIFI_GPIO2 (use as GPIO i/o) + 0 af, \ GPIO_22 - WIFI_GPIO3 (use as GPIO i/o) + 0 af, \ GPIO_23 - CODEC_INT (use as GPIO in) + 1 af, \ GPIO_24 - I2S_SYSCLK (Codec - HI-FI) + 1 af, \ GPIO_25 - SSPA2_SCLK (Codec - HI-FI) + 1 af, \ GPIO_26 - SSPA2_SFRM (Codec - HI-FI) + 1 af, \ GPIO_27 - SSPA2_TXD (Codec - HI-FI) + 1 af, \ GPIO_28 - SSPA2_RXD (Codec - HI-FI) + 1 af, \ GPIO_29 - UART1_RXD (Bluetooth) + 1 af, \ GPIO_30 - UART1_TXD (Bluetooth) + 1 af, \ GPIO_31 - UART1_CTS (Bluetooth) + 1 af, \ GPIO_32 - UART1_RTS (Bluetooth) + 0 af, \ GPIO_33 - SSPA2_CLK (Codec - LO-FI) + 0 af, \ GPIO_34 - SSPA2_FRM (Codec - LO-FI) + 0 af, \ GPIO_35 - SSPA2_TXD (Codec - LO-FI) + 0 af, \ GPIO_36 - SSPA2_RXD (Codec - LO-FI) + 1 af, \ GPIO_37 - MMC2_DAT<3> + 1 af, \ GPIO_38 - MMC2_DAT<2> + 1 af, \ GPIO_39 - MMC2_DAT<1> + 1 af, \ GPIO_40 - MMC2_DAT<0> + 1 af, \ GPIO_41 - MMC2_CMD + 1 af, \ GPIO_42 - MMC2_CLK + 1 af, \ GPIO_43 - TWSI2_SCL (for codec/noise/FM) + 1 af, \ GPIO_44 - TWSI2_SDA (for codec/noise/FM) + 0 af, \ GPIO_45 - WM8994_LDOEN (use as GPIO out) + 0 af, \ GPIO_46 - HDMI_DET (use as GPIO in) + 2 af, \ GPIO_47 - SSP2_CLK + 2 af, \ GPIO_48 - SSP2_FRM + 2 af, \ GPIO_49 - SSP2_RXD + 0 af, \ GPIO_50 - GPS_STBY (use as GPIO out) + 1 af, \ GPIO_51 - UART3_RXD (debug port) + 1 af, \ GPIO_52 - UART3_TXD (debug port) + 5 af, \ GPIO_53 - PWM3 (Keypad backlight) + 4 af, \ GPIO_54 - HDMI_CEC (MOVED to GPIO 113?) + 0 af, \ GPIO_55 - WIFI_GPIO0 (use as GPIO in) + 0 af, \ GPIO_56 - WIFI_GPIO1 (use as GPIO out) + 0 af, \ GPIO_57 - WIFI_PD_N (use as GPIO out) + 0 af, \ GPIO_58 - WIFI_RST_N (use as GPIO out) + 1 af, \ GPIO_59 - CCIC_IN<7> + 1 af, \ GPIO_60 - CCIC_IN<6> + 1 af, \ GPIO_61 - CCIC_IN<5> + 1 af, \ GPIO_62 - CCIC_IN<4> + 1 af, \ GPIO_63 - CCIC_IN<3> + 1 af, \ GPIO_64 - CCIC_IN<2> + 1 af, \ GPIO_65 - CCIC_IN<1> + 1 af, \ GPIO_66 - CCIC_IN<0> + 1 af, \ GPIO_67 - CAM_HSYNC + 1 af, \ GPIO_68 - CAM_VSYNC + 1 af, \ GPIO_69 - CAM_MCLK + 1 af, \ GPIO_70 - CAM_PCLK + 1 af, \ GPIO_71 - TWSI3_SCL (for CAM) + 1 af, \ GPIO_72 - TWSI3_CLK (for CAM) + 0 af, \ GPIO_73 - CCIC_RST_N (use as GPIO out) +\ 0 af, \ GPIO_74 - LED - ORANGE (use as GPIO out) LCD VSYNC +\ 0 af, \ GPIO_75 - LED - BLUE (use as GPIO out) LCD HSYNV +\ 0 af, \ GPIO_76 - LED - RED (use as GPIO out) LCD PCLK +\ 0 af, \ GPIO_77 - LED - GREEN (use as GPIO out) + 4 af, \ GPIO_74 - SSP3_CLK - EC_SPI + 4 af, \ GPIO_75 - SSP3_FRM - EC_SPI + 4 af, \ GPIO_76 - SSP3_TXD - EC_SPI + 4 af, \ GPIO_77 - SSP3_RXD - EC_SPI +\ 5 af, \ GPIO_78 - SSP4_CLK +\ 5 af, \ GPIO_79 - SSP4_FRM + 0 af, \ GPIO_78 - EC_SPI CMD + 0 af, \ GPIO_79 - EC_SPI ACK + 5 af, \ GPIO_80 - SSP4_SDA + 0 af, \ GPIO_81 - VBUS_FLT_N (use as GPIO in) + 0 af, \ GPIO_82 - VBUS_EN (use as GPIO out) + 0 af, \ GPIO_83 - LCD_RST_N (use as GPIO out) + 0 af, \ GPIO_84 - USB_INT_N (use as GPIO in) + 0 af, \ GPIO_85 - USB_RST_N (use as GPIO out) + 0 af, \ GPIO_86 - USB_PWDN_N (use as GPIO out) + 0 af, \ GPIO_87 - USB_HUB_EN (use as GPIO out) + 0 af, \ GPIO_88 - USB_MMC_EN (use as GPIO out) + 0 af, \ GPIO_89 - 5V_Enable (use as GPIO out) + no-update, \ GPIO_90 - Not used + 0 af, \ GPIO_91 - ACC_INT (use as GPIO in) + 0 af, \ GPIO_92 - PROX1_INT (use as GPIO in) + no-update, \ GPIO_93 - Not used + 3 pull-dn, \ GPIO_94 - SPI_CLK + 3 pull-up, \ GPIO_95 - SPI_CSO + 3 pull-dn, \ GPIO_96 - SPI_SDA + 2 af, \ GPIO_97 - TWSI6_SCL (HDMI EDID) + 2 af, \ GPIO_98 - TWSI6_SDA (HDMI EDID) + 4 af, \ GPIO_99 - TWSI5_SCL (CAP TOUCH) + 4 af, \ GPIO_100 - TWSI5_SDA (CAP TOUCH) + 0 af, \ GPIO_101 - TSI_INT (use as GPIO in) + 0 af, \ GPIO_102 - USIM_UCLK + 0 af, \ GPIO_103 - USIM_UIO + 0 af, \ GPIO_104 - ND_IO[7] + 0 af, \ GPIO_105 - ND_IO[6] + 0 af, \ GPIO_106 - ND_IO[5] + 0 af, \ GPIO_107 - ND_IO[4] + 0 af, \ GPIO_108 - ND_IO[15] + 0 af, \ GPIO_109 - ND_IO[14] + 0 af, \ GPIO_110 - ND_IO[13] + 0 af, \ GPIO_111 - ND_IO[8] Use 2 af, for eMMC + 0 af, \ GPIO_112 - ND_RDY[0] Use 2 af, for eMMC + no-update, \ GPIO_113 - Not used + 1 af, \ GPIO_114 - M/N_CLK_OUT (G_CLK_OUT) + 0 af, \ GPIO_115 - GPIO_115 (i/o) + 0 af, \ GPIO_116 - GPIO_116 (i/o) + 0 af, \ GPIO_117 - GPIO_117 (i/o) + 0 af, \ GPIO_118 - GPIO_118 (i/o) + 0 af, \ GPIO_119 - GPIO_119 (i/o) + 0 af, \ GPIO_120 - GPIO_120 (i/o) + 0 af, \ GPIO_121 - GPIO_121 (i/o) + 0 af, \ GPIO_122 - GPIO_122 (i/o) + 0 af, \ GPIO_123 - MBFLT_N (use as GPIO in) + 1 af, \ GPIO_124 - MMC1_DAT[7] + 1 af, \ GPIO_125 - MMC1_DAT[6] + 0 pull-up, \ GPIO_126 - Board Rev ID bit 0 + 0 pull-up, \ GPIO_127 - Board Rev ID bit 1 + 0 pull-up, \ GPIO_128 - Board Rev ID bit 2 + 1 af, \ GPIO_129 - MMC1_DAT[5] + 1 af, \ GPIO_130 - MMC1_DAT[4] + 1 af, \ GPIO_131 - MMC1_DAT[3] + 1 af, \ GPIO_132 - MMC1_DAT[2] + 1 af, \ GPIO_133 - MMC1_DAT[1] + 1 af, \ GPIO_134 - MMC1_DAT[0] + no-update, \ GPIO_135 - Not used + 1 af, \ GPIO_136 - MMC1_CMD + no-update, \ GPIO_137 - Not used + no-update, \ GPIO_138 - Not used + 1 af, \ GPIO_139 - MMC1_CLK + 1 af, \ GPIO_140 - MMC1_CD + 1 af, \ GPIO_141 - MMC1_WP + 0 af, \ GPIO_142 - USIM_RSTn + 0 af, \ GPIO_143 - ND_CS[0] + 0 af, \ GPIO_144 - ND_CS[1] + no-update, \ GPIO_145 - Not used + no-update, \ GPIO_146 - Not used + 0 af, \ GPIO_147 - ND_WE_N + 0 af, \ GPIO_148 - ND_RE_N + 0 af, \ GPIO_149 - ND_CLE + 0 af, \ GPIO_150 - ND_ALE + 2 af, \ GPIO_151 - MMC3_CLK + no-update, \ GPIO_152 - Not used + no-update, \ GPIO_153 - Not used + 0 af, \ GPIO_154 - SM_INT + 1 af, \ MMC3_RST_N (use as GPIO) + no-update, \ GPIO_156 - PRI_TDI (JTAG) + no-update, \ GPIO_157 - PRI_TDS (JTAG) + no-update, \ GPIO_158 - PRI_TDK (JTAG) + no-update, \ GPIO_159 - PRI_TDO (JTAG) + 0 af, \ GPIO_160 - ND_RDY[1] + 0 af, \ GPIO_161 - ND_IO[12] + 0 af, \ GPIO_162 - ND_IO[11] Use 2 af, for eMMC + 0 af, \ GPIO_163 - ND_IO[10] Use 2 af, for eMMC + 0 af, \ GPIO_164 - ND_IO[9] Use 2 af, for eMMC + 0 af, \ GPIO_165 - ND_IO[3] Use 2 af, for eMMC + 0 af, \ GPIO_166 - ND_IO[2] Use 2 af, for eMMC + 0 af, \ GPIO_167 - ND_IO[1] Use 2 af, for eMMC + 0 af, \ GPIO_168 - ND_IO[0] Use 2 af, for eMMC + +: init-mfprs + d# 169 0 do + mfpr-table i wa+ w@ ( code ) + dup 8 = if ( code ) + drop ( ) + else ( code ) + i af! ( ) + then + loop +; + +: gpios-for-nand ( -- ) + h# c0 d# 111 af! + h# c0 d# 112 af! + d# 169 d# 162 do h# c0 i af! loop +; +: gpios-for-emmc ( -- ) + h# c2 d# 111 af! + h# c2 d# 112 af! + d# 169 d# 162 do h# c2 i af! loop +;
Added: cpu/arm/mmp2/boardtwsi.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/boardtwsi.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,172 @@ +purpose: Board-specific details of TWSI-connected devices + +\ TWSI devices per channel: +\ 1 MAX8925 PMIC MAIN 78, PMIC ADC 8e, PMIC RTC d0, MAX8649 c0 +\ 2 WM8994 Audio Codec 34, WM2000 Noise Canceler 74 +\ 3 m6M0 Camera ISP 3e, OV8810 Camera 6c +\ 4 HMC5843 compass 3c, CM3623 ALS/PS 20+22+b0, BMA150 accelerometer 70 +\ 5 TC358762 MIPI bridge 16, TM-1210 or TM1414 touchscreen 40 +\ 6 HDMI DDC EDID a0 + +: select-touch-panel ( -- ) h# 40 5 set-twsi-target ; +: touch-panel-type ( -- n ) select-touch-panel h# bd twsi-b@ ; +: get-tm1414-data ( -- x y finger-mask ) + select-touch-panel ( ) + h# 1a twsi-b@ ( low-y,low-x ) + dup h# f and h# 18 twsi-b@ 4 lshift or ( low-y,low-x x ) + swap 4 rshift h# f and h# 19 twsi-b@ 4 lshift or ( x y ) + h# 15 twsi-b@ ( x y mask ) +; +: touchpad@ ( -- x y finger-mask ) get-tm1414-data ; + +: get-tm1210-data ( -- x y reg7-flick-magnitude reg6-gesture reg0-finger-count ) + 3 twsi-b@ 2 twsi-b@ bwjoin ( x ) + 5 twsi-b@ 4 twsi-b@ bwjoin ( x y ) + + 7 twsi-b@ + 6 twsi-b@ + 0 twsi-b@ +; + +: compass@ ( -- x y z temp id ) + h# 3c 4 set-twsi-target + 0 0 twsi-b! \ Config register A + h# 50 1 twsi-b! \ Config register B + 0 2 twsi-b! \ Mode register + 4 twsi-b@ 3 twsi-b@ bwjoin ( x ) + 6 twsi-b@ 5 twsi-b@ bwjoin ( x y ) + 8 twsi-b@ 7 twsi-b@ bwjoin ( x y z ) + h# b twsi-b@ ( x y z temp ) + h# a twsi-b@ 9 twsi-b@ bwjoin ( x y z temp id ) +; + +: select-pmic ( -- ) h# 78 1 set-twsi-target ; + +: accel-power-on ( -- ) \ LDO8 - vout is 36, ctl is 34 + select-pmic + d# 3000 d# 750 - d# 50 / h# 36 twsi-b! \ want 3.0V + h# 1f h# 34 twsi-b! +; +: accel-power-off ( -- ) \ LDO8 - vout is 36, ctl is 34 + select-pmic + h# 1e h# 34 twsi-b! +; +: accel@ ( -- x y z temp id ) + h# 70 4 set-twsi-target + + 2 twsi-b@ 6 rshift ( x-low ) + 3 twsi-b@ 2 lshift or ( x ) + + 4 twsi-b@ 6 rshift ( x y-low ) + 5 twsi-b@ 2 lshift or ( x y ) + + 6 twsi-b@ 6 rshift ( x y z-low ) + 7 twsi-b@ 2 lshift or ( x y z ) + + 8 twsi-b@ 0 twsi-b@ ( x y z temp id ) +; + +: init-pals ( -- ) + h# b0 4 set-twsi-target \ Set PS parameters address + 0 1 twsi-write \ clear interrupt settings + + h# 22 4 set-twsi-target \ Device init address + h# 10 1 twsi-write \ Init device + + h# 20 4 set-twsi-target \ Ambient Light Sensor address + 2 1 twsi-write \ Enable ALS in most sensitive mode, 16-bit data +; +: als@ ( -- n ) + h# 22 4 set-twsi-target \ Ambient Light Sensor LSB address + 0 1 twsi-get ( low ) + h# 20 4 set-twsi-target \ Ambient Light Sensor MSB address + 0 1 twsi-get bwjoin ( n ) +; + +: proximity@ ( -- byte ) + h# b0 4 set-twsi-target \ Proximity Sensor address + 0 1 twsi-get ( byte ) +; + +: lcd-backlight! ( b.intensity -- ) + select-pmic ( b.intensity ) + dup if ( b.intensity ) + h# 85 twsi-b! ( ) + h# 84 twsi-b@ 1 or h# 84 twsi-b! \ Turn on first LED string + else ( 0 ) + drop ( ) + h# 84 twsi-b@ 1 invert and h# 84 twsi-b! \ Turn off first LED string + then +; + +: keypad-backlight! ( b.intensity -- ) + select-pmic ( b.intensity ) + dup if ( b.intensity ) + h# 85 twsi-b! ( ) + h# 84 twsi-b@ 3 or h# 84 twsi-b! \ Turn on both LED strings + else ( ) + h# 84 twsi-b@ 3 invert and h# 84 twsi-b! \ Turn off both LED strings + then +; + +: power-on-dsi ( -- ) + select-pmic + + h# 16 h# 22 twsi-b! \ 1.2 volts for LDO3 + h# 1f h# 20 twsi-b! \ LDO3 enable + + h# 16 h# 16 twsi-b! \ 1.2 volts for LDO17 + h# 1f h# 14 twsi-b! \ LDO17 enable + + h# 1f h# 34 twsi-b! \ LDO8 enable + + d# 10 ms +; + +: bcd> ( bcd -- binary ) + dup h# f and swap 4 rshift d# 10 * + +; +: twsi-bcd@ ( reg# -- binary ) twsi-b@ bcd> ; +: get-rtc ( -- ) + h# d0 1 set-twsi-target + +\ 3 twsi-b@ ( dow ) +\ + + 0 twsi-bcd@ ( sec ) + 1 twsi-bcd@ ( sec min ) + 2 twsi-bcd@ ( sec min hr ) + 4 twsi-bcd@ ( sec min hr day ) + 5 twsi-bcd@ ( sec min hr day mon ) + 6 twsi-bcd@ d# 2000 + ( sec min hr day yr ) +; + +: core-voltage! ( mv -- ) + h# c0 1 set-twsi-target \ MAX8649 power management IC + + d# 750 umax d# 1350 umin \ Clipped voltage + d# 750 - d# 10 / ( offset-in-mv/10 ) + h# 80 or ( code ) + 2 twsi-b! +; +: core-voltage@ ( -- mv ) + h# c0 1 set-twsi-target \ MAX8649 power management IC + 2 twsi-b@ ( code ) + h# 7f and ( offset-mv/10 ) + d# 10 * ( offset-mv ) + d# 750 + +; +: .core-voltage ( -- ) core-voltage@ .d ; + +: vibrate-on ( -- ) select-pmic h# 1f h# 3c twsi-b! ; \ LDO10 +: vibrate-off ( -- ) select-pmic h# 1e h# 3c twsi-b! ; + +: power-on-sd ( -- ) + select-pmic + h# 29 h# 42 twsi-b! + h# 1f h# 40 twsi-b! +; +: power-off-sd ( -- ) + select-pmic + h# 1e h# 40 twsi-b! +;
Modified: cpu/arm/mmp2/config.fth ============================================================================== --- cpu/arm/mmp2/config.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/config.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -1,3 +1,4 @@ create debug-startup
fload ${BP}/cpu/arm/mmp2/addrs.fth +fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
Modified: cpu/arm/mmp2/devices.fth ============================================================================== --- cpu/arm/mmp2/devices.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/devices.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -46,6 +46,10 @@ fload ${BP}/cpu/arm/mmp2/timer.fth fload ${BP}/cpu/arm/mmp2/twsi.fth fload ${BP}/cpu/arm/mmp2/mfpr.fth +fload ${BP}/cpu/arm/mmp2/gpio.fth + +fload ${BP}/cpu/arm/mmp2/boardtwsi.fth +fload ${BP}/cpu/arm/mmp2/boardgpio.fth : init-stuff set-camera-domain-voltage acgr-clocks-on @@ -60,31 +64,12 @@ init-stuff ;
-fload ${BP}/cpu/arm/mmp2/gpio.fth fload ${BP}/cpu/arm/mmp2/irq.fth
fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer
-0 0 " d4018000" " /" begin-package - " uart" name - h# d4018000 h# 20 reg - - : write ( adr len -- actual ) - 0 max tuck ( actual adr actual ) - bounds ?do i c@ uemit loop ( actual ) - ; - : read ( adr len -- actual ) - 0= if drop 0 exit then - ukey? if ( adr ) - ukey swap c! 1 ( actual ) - else ( adr ) - drop -2 ( -2 ) - then - ; - : open ( -- okay? ) true ; - : close ( -- ) ; - : install-abort ; - : remove-abort ; +0 0 " d4018000" " /" begin-package \ UART3 + fload ${BP}/cpu/arm/mmp2/uart.fth end-package devalias com1 /uart : com1 " com1" ; @@ -135,6 +120,26 @@
fload ${BP}/dev/olpc/kb3700/spicmd.fth
+0 0 " d4208000" " /" begin-package + h# 200 constant /regs + my-address my-space /regs reg + : my-map-in ( len -- adr ) + my-space swap " map-in" $call-parent h# 100 + ( adr ) + 3 over h# a8 + rl! ( adr ) \ Force host mode + ; + : my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ; + false constant has-dbgp-regs? + false constant needs-dummy-qh? + false constant grab-controller + fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth +end-package + +: usb-power-on ( -- ) d# 82 gpio-set ; \ 1 instead of 82 for XO + +fload ${BP}/cpu/arm/marvell/utmiphy.fth +stand-init: Init USB Phy + init-usb-phy +;
\ LICENSE_BEGIN \ Copyright (c) 2010 FirmWorks
Modified: cpu/arm/mmp2/dsi.fth ============================================================================== --- cpu/arm/mmp2/dsi.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/dsi.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -45,7 +45,7 @@ 2 ms d# 83 gpio-clr 1 ms d# 83 gpio-set 1 ms \ LCD_RST_N line resets DSI bridge
- 5 set-address h# 16 set-slave \ TWSI address of TC358762 MIPI DSI bridge + h# 16 5 set-twsi-target \ TWSI address of TC358762 MIPI DSI bridge \ Data Reg#....... 0 h# 047c dsi-twsi! \ Turn off sleep mode 2 ms @@ -142,7 +142,7 @@ : .dsi ( index -- ) dup 3 u.r space dsi-twsi@ 8 u.r cr ; : .dsiw ( index -- ) dup 3 u.r space dsi-twsi-w@ 8 u.r cr ; : dump-dsi ( -- ) - 5 set-address 16 set-slave + 16 5 set-twsi-target 47c .dsi 210 .dsi 470 .dsi
Modified: cpu/arm/mmp2/fw.bth ============================================================================== --- cpu/arm/mmp2/fw.bth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/fw.bth Mon Oct 18 06:02:38 2010 (r1987) @@ -215,7 +215,6 @@ true to stand-init-debug?
: protect-fw ( -- ) ; -: usb-power-on ( -- ) ;
hex : i-key-wait ( ms -- pressed? ) @@ -236,7 +235,6 @@
standalone? if disable-interrupts -[ifdef] notdef d# 1000 i-key-wait if \ protect-fw @@ -244,7 +242,6 @@ then \ Turn on USB power here to overlap the time with other startup actions usb-power-on -[then] then ; warning !
Added: cpu/arm/mmp2/hwaddrs.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/hwaddrs.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,11 @@ +\ Defined by MMP2 hardware +h# d401.9000 constant gpio-base +h# d405.1024 constant acgr-pa +h# d401.5000 constant clock-unit-pa +h# d405.0000 constant main-pmu-pa +h# d428.2800 constant pmua-pa \ Application processor PMU register base +h# d420.b800 constant dsi1-pa \ 4-lane controller +h# d420.ba00 constant dsi2-pa \ 3-lane controller +h# d420.b000 constant lcd-pa +h# d401.4000 constant timer-pa +
Modified: cpu/arm/mmp2/mfpr.fth ============================================================================== --- cpu/arm/mmp2/mfpr.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/mfpr.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -1,26 +1,12 @@ +purpose: Pin multiplexing for ARMADA 610 chip (no board details) + : aib-unlock h# baba h# d4015068 l! \ Unlock sequence h# eb10 h# d401506c l! ; -: set-camera-domain-voltage - aib-unlock - h# d401e80c l@ 4 or ( n ) \ Set 1.8V selector bit in AIB_GPIO2_IO - aib-unlock - h# d401e80c l! -; : acgr-clocks-on ( -- ) h# 0818.F33C acgr-pa l! \ Turn on all clocks ; -: set-gpio-directions ( -- ) - 3 h# 38 clock-unit-pa + l! \ Enable clocks in GPIO clock reset register - - h# 000e.0000 gpio-base h# 0c + l! \ Bits 19, 18, 17 - h# 0704.2000 gpio-base h# 10 + l! \ Bits 58,57,56,50 and 45 -\ h# 03ec.3e00 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:73 - h# 03ec.3200 gpio-base h# 14 + l! \ Bits 89:85,83,82, and 77:76 and 73 (leave 74 and 75 as input) - - h# 0200.3c00 gpio-base h# 20 + l! \ Turn off LEDS (3c00) and turn on 5V (0200.0000) -;
hex create mfpr-offsets \ GPIOs @@ -60,211 +46,8 @@ ;
: no-update, ( -- ) 8 w, ; \ 8 is a reserved bit; the code skips these +: af@ ( gpio# -- function# ) gpio>mfpr l@ ; +: af! ( function# gpio# -- ) gpio>mfpr l! ; : af, ( n -- ) h# c0 + w, ; : pull-up, ( n -- ) h# c0c0 + w, ; : pull-dn, ( n -- ) h# a0c0 + w, ; - -create mfpr-table - 1 af, \ GPIO_00 - KP_MKIN[0] - 1 af, \ GPIO_01 - KP_MKOUT[0] - 1 af, \ GPIO_02 - KP_MKIN[1] - 1 af, \ GPIO_03 - KP_MKOUT[1] - 1 af, \ GPIO_04 - KP_MKIN[2] - 1 af, \ GPIO_05 - KP_MKOUT[2] - no-update, \ GPIO_06 - Not used - no-update, \ GPIO_07 - Not used - no-update, \ GPIO_08 - Not used - no-update, \ GPIO_09 - Not used - no-update, \ GPIO_10 - Not used - no-update, \ GPIO_11 - Not used - no-update, \ GPIO_12 - Not used - no-update, \ GPIO_13 - Not used - no-update, \ GPIO_14 - Not used - no-update, \ GPIO_15 - Not used - no-update, \ GPIO_16 - Not used - 0 af, \ GPIO_17 - BB_GPIO1 (use as GPIO out) - 0 af, \ GPIO_18 - BB_GPIO2 (use as GPIO out) - 0 af, \ GPIO_19 - BB_GPIO3 (use as GPIO out) - 0 af, \ GPIO_20 - ISP_INT (use as GPIO in) - 0 af, \ GPIO_21 - WIFI_GPIO2 (use as GPIO i/o) - 0 af, \ GPIO_22 - WIFI_GPIO3 (use as GPIO i/o) - 0 af, \ GPIO_23 - CODEC_INT (use as GPIO in) - 1 af, \ GPIO_24 - I2S_SYSCLK (Codec - HI-FI) - 1 af, \ GPIO_25 - SSPA2_SCLK (Codec - HI-FI) - 1 af, \ GPIO_26 - SSPA2_SFRM (Codec - HI-FI) - 1 af, \ GPIO_27 - SSPA2_TXD (Codec - HI-FI) - 1 af, \ GPIO_28 - SSPA2_RXD (Codec - HI-FI) - 1 af, \ GPIO_29 - UART1_RXD (Bluetooth) - 1 af, \ GPIO_30 - UART1_TXD (Bluetooth) - 1 af, \ GPIO_31 - UART1_CTS (Bluetooth) -\ - 1 af, \ GPIO_32 - UART1_RTS (Bluetooth) - 0 af, \ GPIO_33 - SSPA2_CLK (Codec - LO-FI) - 0 af, \ GPIO_34 - SSPA2_FRM (Codec - LO-FI) - 0 af, \ GPIO_35 - SSPA2_TXD (Codec - LO-FI) - 0 af, \ GPIO_36 - SSPA2_RXD (Codec - LO-FI) - 1 af, \ GPIO_37 - MMC2_DAT<3> - 1 af, \ GPIO_38 - MMC2_DAT<2> - 1 af, \ GPIO_39 - MMC2_DAT<1> - 1 af, \ GPIO_40 - MMC2_DAT<0> - 1 af, \ GPIO_41 - MMC2_CMD - 1 af, \ GPIO_42 - MMC2_CLK - 1 af, \ GPIO_43 - TWSI2_SCL (for codec/noise/FM) - 1 af, \ GPIO_44 - TWSI2_SDA (for codec/noise/FM) - 0 af, \ GPIO_45 - WM8994_LDOEN (use as GPIO out) - 0 af, \ GPIO_46 - HDMI_DET (use as GPIO in) - 2 af, \ GPIO_47 - SSP2_CLK - 2 af, \ GPIO_48 - SSP2_FRM - 2 af, \ GPIO_49 - SSP2_RXD - 0 af, \ GPIO_50 - GPS_STBY (use as GPIO out) - 1 af, \ GPIO_51 - UART3_RXD (debug port) - 1 af, \ GPIO_52 - UART3_TXD (debug port) - 5 af, \ GPIO_53 - PWM3 (Keypad backlight) - 4 af, \ GPIO_54 - HDMI_CEC (MOVED to GPIO 113?) - 0 af, \ GPIO_55 - WIFI_GPIO0 (use as GPIO in) - 0 af, \ GPIO_56 - WIFI_GPIO1 (use as GPIO out) - 0 af, \ GPIO_57 - WIFI_PD_N (use as GPIO out) - 0 af, \ GPIO_58 - WIFI_RST_N (use as GPIO out) - 1 af, \ GPIO_59 - CCIC_IN<7> - 1 af, \ GPIO_60 - CCIC_IN<6> - 1 af, \ GPIO_61 - CCIC_IN<5> - 1 af, \ GPIO_62 - CCIC_IN<4> - 1 af, \ GPIO_63 - CCIC_IN<3> -\ - 1 af, \ GPIO_64 - CCIC_IN<2> - 1 af, \ GPIO_65 - CCIC_IN<1> - 1 af, \ GPIO_66 - CCIC_IN<0> - 1 af, \ GPIO_67 - CAM_HSYNC - 1 af, \ GPIO_68 - CAM_VSYNC - 1 af, \ GPIO_69 - CAM_MCLK - 1 af, \ GPIO_70 - CAM_PCLK - 1 af, \ GPIO_71 - TWSI3_SCL (for CAM) - 1 af, \ GPIO_72 - TWSI3_CLK (for CAM) - 0 af, \ GPIO_73 - CCIC_RST_N (use as GPIO out) -\ 0 af, \ GPIO_74 - LED - ORANGE (use as GPIO out) LCD VSYNC -\ 0 af, \ GPIO_75 - LED - BLUE (use as GPIO out) LCD HSYNV -\ 0 af, \ GPIO_76 - LED - RED (use as GPIO out) LCD PCLK -\ 0 af, \ GPIO_77 - LED - GREEN (use as GPIO out) - 4 af, \ GPIO_74 - SSP3_CLK - EC_SPI - 4 af, \ GPIO_75 - SSP3_FRM - EC_SPI - 4 af, \ GPIO_76 - SSP3_TXD - EC_SPI - 4 af, \ GPIO_77 - SSP3_RXD - EC_SPI -\ 5 af, \ GPIO_78 - SSP4_CLK -\ 5 af, \ GPIO_79 - SSP4_FRM - 0 af, \ GPIO_78 - EC_SPI CMD - 0 af, \ GPIO_79 - EC_SPI ACK - 5 af, \ GPIO_80 - SSP4_SDA - 0 af, \ GPIO_81 - VBUS_FLT_N (use as GPIO in) - 0 af, \ GPIO_82 - VBUS_EN (use as GPIO out) - 0 af, \ GPIO_83 - LCD_RST_N (use as GPIO out) - 0 af, \ GPIO_84 - USB_INT_N (use as GPIO in) - 0 af, \ GPIO_85 - USB_RST_N (use as GPIO out) - 0 af, \ GPIO_86 - USB_PWDN_N (use as GPIO out) - 0 af, \ GPIO_87 - USB_HUB_EN (use as GPIO out) - 0 af, \ GPIO_88 - USB_MMC_EN (use as GPIO out) - 0 af, \ GPIO_89 - 5V_Enable (use as GPIO out) - no-update, \ GPIO_90 - Not used - 0 af, \ GPIO_91 - ACC_INT (use as GPIO in) - 0 af, \ GPIO_92 - PROX1_INT (use as GPIO in) - no-update, \ GPIO_93 - Not used - 3 pull-dn, \ GPIO_94 - SPI_CLK - 3 pull-up, \ GPIO_95 - SPI_CSO -\ - 3 pull-dn, \ GPIO_96 - SPI_SDA - 2 af, \ GPIO_97 - TWSI6_SCL (HDMI EDID) - 2 af, \ GPIO_98 - TWSI6_SDA (HDMI EDID) - 4 af, \ GPIO_99 - TWSI5_SCL (CAP TOUCH) - 4 af, \ GPIO_100 - TWSI5_SDA (CAP TOUCH) - 0 af, \ GPIO_101 - TSI_INT (use as GPIO in) - 0 af, \ GPIO_102 - USIM_UCLK - 0 af, \ GPIO_103 - USIM_UIO - 0 af, \ GPIO_104 - ND_IO[7] - 0 af, \ GPIO_105 - ND_IO[6] - 0 af, \ GPIO_106 - ND_IO[5] - 0 af, \ GPIO_107 - ND_IO[4] - 0 af, \ GPIO_108 - ND_IO[15] - 0 af, \ GPIO_109 - ND_IO[14] - 0 af, \ GPIO_110 - ND_IO[13] - 0 af, \ GPIO_111 - ND_IO[8] Use 2 af, for eMMC - 0 af, \ GPIO_112 - ND_RDY[0] Use 2 af, for eMMC - no-update, \ GPIO_113 - Not used - 1 af, \ GPIO_114 - M/N_CLK_OUT (G_CLK_OUT) - 0 af, \ GPIO_115 - GPIO_115 (i/o) - 0 af, \ GPIO_116 - GPIO_116 (i/o) - 0 af, \ GPIO_117 - GPIO_117 (i/o) - 0 af, \ GPIO_118 - GPIO_118 (i/o) - 0 af, \ GPIO_119 - GPIO_119 (i/o) - 0 af, \ GPIO_120 - GPIO_120 (i/o) - 0 af, \ GPIO_121 - GPIO_121 (i/o) - 0 af, \ GPIO_122 - GPIO_122 (i/o) - 0 af, \ GPIO_123 - MBFLT_N (use as GPIO in) - 1 af, \ GPIO_124 - MMC1_DAT[7] - 1 af, \ GPIO_125 - MMC1_DAT[6] - 0 pull-up, \ GPIO_126 - Board Rev ID bit 0 - 0 pull-up, \ GPIO_127 - Board Rev ID bit 1 -\ - 0 pull-up, \ GPIO_128 - Board Rev ID bit 2 - 1 af, \ GPIO_129 - MMC1_DAT[5] - 1 af, \ GPIO_130 - MMC1_DAT[4] - 1 af, \ GPIO_131 - MMC1_DAT[3] - 1 af, \ GPIO_132 - MMC1_DAT[2] - 1 af, \ GPIO_133 - MMC1_DAT[1] - 1 af, \ GPIO_134 - MMC1_DAT[0] - no-update, \ GPIO_135 - Not used - 1 af, \ GPIO_136 - MMC1_CMD - no-update, \ GPIO_137 - Not used - no-update, \ GPIO_138 - Not used - 1 af, \ GPIO_139 - MMC1_CLK - 1 af, \ GPIO_140 - MMC1_CD - 1 af, \ GPIO_141 - MMC1_WP - 0 af, \ GPIO_142 - USIM_RSTn - 0 af, \ GPIO_143 - ND_CS[0] - 0 af, \ GPIO_144 - ND_CS[1] - no-update, \ GPIO_145 - Not used - no-update, \ GPIO_146 - Not used - 0 af, \ GPIO_147 - ND_WE_N - 0 af, \ GPIO_148 - ND_RE_N - 0 af, \ GPIO_149 - ND_CLE - 0 af, \ GPIO_150 - ND_ALE - 2 af, \ GPIO_151 - MMC3_CLK - no-update, \ GPIO_152 - Not used - no-update, \ GPIO_153 - Not used - 0 af, \ GPIO_154 - SM_INT - 1 af, \ MMC3_RST_N (use as GPIO) - no-update, \ GPIO_156 - PRI_TDI (JTAG) - no-update, \ GPIO_157 - PRI_TDS (JTAG) - no-update, \ GPIO_158 - PRI_TDK (JTAG) - no-update, \ GPIO_159 - PRI_TDO (JTAG) -\ - 0 af, \ GPIO_160 - ND_RDY[1] - 0 af, \ GPIO_161 - ND_IO[12] - 0 af, \ GPIO_162 - ND_IO[11] Use 2 af, for eMMC - 0 af, \ GPIO_163 - ND_IO[10] Use 2 af, for eMMC - 0 af, \ GPIO_164 - ND_IO[9] Use 2 af, for eMMC - 0 af, \ GPIO_165 - ND_IO[3] Use 2 af, for eMMC - 0 af, \ GPIO_166 - ND_IO[2] Use 2 af, for eMMC - 0 af, \ GPIO_167 - ND_IO[1] Use 2 af, for eMMC - 0 af, \ GPIO_168 - ND_IO[0] Use 2 af, for eMMC - -: init-mfprs - d# 169 0 do - mfpr-table i wa+ w@ ( code ) - dup 8 = if ( code ) - drop ( ) - else ( code ) - i gpio>mfpr l! ( ) - then - loop -; - -: af! ( function# gpio# -- ) gpio>mfpr l! ; -: gpios-for-nand ( -- ) - h# c0 d# 111 af! - h# c0 d# 112 af! - d# 169 d# 162 do h# c0 i af! loop -; -: gpios-for-emmc ( -- ) - h# c2 d# 111 af! - h# c2 d# 112 af! - d# 169 d# 162 do h# c2 i af! loop -;
Modified: cpu/arm/mmp2/timer.fth ============================================================================== --- cpu/arm/mmp2/timer.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/timer.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -21,7 +21,7 @@ 7 h# 84 timer! ;
- +[ifdef] arm-assembler code timer0@ ( -- n ) \ 6.5 MHz psh tos,sp set r1,0xD4014000 @@ -48,6 +48,11 @@ mov r0,r0 ldr tos,[r1,#0x30] c; +[else] +: timer0@ ( -- n ) 1 h# d40140a4 l! h# d4014028 l@ ; +: timer1@ ( -- n ) 1 h# d40140a8 l! h# d401402c l@ ; +: timer2@ ( -- n ) 1 h# d40140ac l! h# d4014030 l@ ; +[then]
: timer0-status@ ( -- n ) h# d4014034 l@ ; : timer1-status@ ( -- n ) h# d4014038 l@ ;
Modified: cpu/arm/mmp2/twsi.fth ============================================================================== --- cpu/arm/mmp2/twsi.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/mmp2/twsi.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -23,20 +23,14 @@ create clock-offsets h# 04 c, h# 08 c, h# 0c c, h# 10 c, h# 7c c, h# 80 c,
-create slave-addresses \ per channel -h# 78 c, \ 1 MAX8925 PMIC MAIN 78, PMIC ADC 8e, PMIC RTC d0, MAX8649 c0 -h# 34 c, \ 2 WM8994 Audio Codec 34, WM2000 Noise Canceler 74 -h# 3e c, \ 3 m6M0 Camera ISP 3e, OV8810 Camera 6c -h# 3c c, \ 4 HMC5843 compass 3c, CM3623 ALS/PS 20+22+b0, BMA150 accelerometer 70 -h# 16 c, \ 5 TC358762 MIPI bridge 16, TM-1210 or TM1414 touchscreen 40 -h# a0 c, \ 6 HDMI DDC EDID a0 - -: set-slave ( n -- ) to slave-address ; -: set-address ( n -- ) \ Channel numbers range from 1 to 6 +: set-twsi-channel ( channel -- ) 1- - channel-bases over na+ @ to chip ( n ) - dup clock-offsets + c@ clock-unit-pa + to clock-reg ( n ) - slave-addresses + c@ set-slave + channel-bases over na+ @ to chip ( channel ) + clock-offsets + c@ clock-unit-pa + to clock-reg ( ) +; +: set-twsi-target ( slave channel -- ) \ Channel numbers range from 1 to 6 + set-twsi-channel + to slave-address ;
\ Bit defines @@ -56,7 +50,7 @@
bbu_ICR_IUE bbu_ICR_SCLE or constant iue+scle : init-twsi-channel ( channel# -- ) - set-address + set-twsi-channel 7 clock-reg l! 3 clock-reg l! \ Set then clear reset bit 1 us iue+scle bbu_ICR_UR or cr! \ Reset the unit @@ -64,6 +58,9 @@ 0 sar! \ Set host slave address 0 cr! \ Disable interrupts ; +: init-twsi ( -- ) + 7 1 do i init-twsi-channel loop +;
: twsi-run ( extra-flags -- ) iue+scle or bbu_ICR_TB or cr! ( ) @@ -140,186 +137,3 @@
: twsi-b@ ( reg -- byte ) 1 1 twsi-get ; : twsi-b! ( byte reg -- ) 2 twsi-write ; - -: select-touch-panel ( -- ) - 5 set-address - h# 40 set-slave -; -: touch-panel-type ( -- n ) - select-touch-panel - h# bd twsi-b@ -; -: get-tm1414-data ( -- x y finger-mask ) - select-touch-panel ( ) - h# 1a twsi-b@ ( low-y,low-x ) - dup h# f and h# 18 twsi-b@ 4 lshift or ( low-y,low-x x ) - swap 4 rshift h# f and h# 19 twsi-b@ 4 lshift or ( x y ) - h# 15 twsi-b@ ( x y mask ) -; -: touchpad@ ( -- x y finger-mask ) get-tm1414-data ; - -: get-tm1210-data ( -- x y reg7-flick-magnitude reg6-gesture reg0-finger-count ) - 3 twsi-b@ 2 twsi-b@ bwjoin ( x ) - 5 twsi-b@ 4 twsi-b@ bwjoin ( x y ) - - 7 twsi-b@ - 6 twsi-b@ - 0 twsi-b@ -; - -: select-compass ( -- ) - 4 set-address - h# 3c set-slave -; - -: compass@ ( -- x y z temp id ) - select-compass - 0 0 twsi-b! \ Config register A - h# 50 1 twsi-b! \ Config register B - 0 2 twsi-b! \ Mode register - 4 twsi-b@ 3 twsi-b@ bwjoin ( x ) - 6 twsi-b@ 5 twsi-b@ bwjoin ( x y ) - 8 twsi-b@ 7 twsi-b@ bwjoin ( x y z ) - h# b twsi-b@ ( x y z temp ) - h# a twsi-b@ 9 twsi-b@ bwjoin ( x y z temp id ) -; - -: select-pmic ( -- ) 1 set-address h# 78 set-slave ; - -: accel-power-on ( -- ) \ LDO8 - vout is 36, ctl is 34 - select-pmic - d# 3000 d# 750 - d# 50 / h# 36 twsi-b! \ want 3.0V - h# 1f h# 34 twsi-b! -; -: accel-power-off ( -- ) \ LDO8 - vout is 36, ctl is 34 - select-pmic - h# 1e h# 34 twsi-b! -; -: accel@ ( -- x y z temp id ) - 4 set-address - h# 70 set-slave - - 2 twsi-b@ 6 rshift ( x-low ) - 3 twsi-b@ 2 lshift or ( x ) - - 4 twsi-b@ 6 rshift ( x y-low ) - 5 twsi-b@ 2 lshift or ( x y ) - - 6 twsi-b@ 6 rshift ( x y z-low ) - 7 twsi-b@ 2 lshift or ( x y z ) - - 8 twsi-b@ 0 twsi-b@ ( x y z temp id ) -; - -: init-pals ( -- ) - 4 set-address - - h# b0 set-slave \ Set PS parameters address - 0 1 twsi-write \ clear interrupt settings - - h# 22 set-slave \ Device init address - h# 10 1 twsi-write \ Init device - - h# 20 set-slave \ Ambient Light Sensor address - 2 1 twsi-write \ Enable ALS in most sensitive mode, 16-bit data -; -: als@ ( -- n ) - 4 set-address - h# 22 set-slave \ Ambient Light Sensor LSB address - 0 1 twsi-get ( low ) - h# 20 set-slave \ Ambient Light Sensor MSB address - 0 1 twsi-get bwjoin ( n ) -; - -: proximity@ ( -- byte ) - 4 set-address - h# b0 set-slave \ Proximity Sensor address - 0 1 twsi-get ( byte ) -; - -: lcd-backlight! ( b.intensity -- ) - select-pmic ( b.intensity ) - dup if ( b.intensity ) - h# 85 twsi-b! ( ) - h# 84 twsi-b@ 1 or h# 84 twsi-b! \ Turn on first LED string - else ( 0 ) - drop ( ) - h# 84 twsi-b@ 1 invert and h# 84 twsi-b! \ Turn off first LED string - then -; - -: keypad-backlight! ( b.intensity -- ) - select-pmic ( b.intensity ) - dup if ( b.intensity ) - h# 85 twsi-b! ( ) - h# 84 twsi-b@ 3 or h# 84 twsi-b! \ Turn on both LED strings - else ( ) - h# 84 twsi-b@ 3 invert and h# 84 twsi-b! \ Turn off both LED strings - then -; - -: init-twsi ( -- ) - 7 1 do i init-twsi-channel loop -; -: power-on-dsi ( -- ) - select-pmic - - h# 16 h# 22 twsi-b! \ 1.2 volts for LDO3 - h# 1f h# 20 twsi-b! \ LDO3 enable - - h# 16 h# 16 twsi-b! \ 1.2 volts for LDO17 - h# 1f h# 14 twsi-b! \ LDO17 enable - - h# 1f h# 34 twsi-b! \ LDO8 enable - - d# 10 ms -; - -: bcd> ( bcd -- binary ) - dup h# f and swap 4 rshift d# 10 * + -; -: twsi-bcd@ ( reg# -- binary ) twsi-b@ bcd> ; -: get-rtc ( -- ) - 1 set-address - h# d0 set-slave - -\ 3 twsi-b@ ( dow ) -\ - - 0 twsi-bcd@ ( sec ) - 1 twsi-bcd@ ( sec min ) - 2 twsi-bcd@ ( sec min hr ) - 4 twsi-bcd@ ( sec min hr day ) - 5 twsi-bcd@ ( sec min hr day mon ) - 6 twsi-bcd@ d# 2000 + ( sec min hr day yr ) -; - -: core-voltage! ( mv -- ) - 1 set-address h# c0 set-slave \ MAX8649 power management IC - - d# 750 umax d# 1350 umin \ Clipped voltage - d# 750 - d# 10 / ( offset-in-mv/10 ) - h# 80 or ( code ) - 2 twsi-b! -; -: core-voltage@ ( -- mv ) - 1 set-address h# c0 set-slave \ MAX8649 power management IC - 2 twsi-b@ ( code ) - h# 7f and ( offset-mv/10 ) - d# 10 * ( offset-mv ) - d# 750 + -; -: .core-voltage ( -- ) core-voltage@ .d ; - -: vibrate-on ( -- ) select-pmic h# 1f h# 3c twsi-b! ; \ LDO10 -: vibrate-off ( -- ) select-pmic h# 1e h# 3c twsi-b! ; - -: power-on-sd ( -- ) - select-pmic - h# 29 h# 42 twsi-b! - h# 1f h# 40 twsi-b! -; -: power-off-sd ( -- ) - select-pmic - h# 1e h# 40 twsi-b! -;
Added: cpu/arm/mmp2/uart.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/uart.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,19 @@ + " uart" name + my-space h# 20 reg + + : write ( adr len -- actual ) + 0 max tuck ( actual adr actual ) + bounds ?do i c@ uemit loop ( actual ) + ; + : read ( adr len -- actual ) + 0= if drop 0 exit then + ukey? if ( adr ) + ukey swap c! 1 ( actual ) + else ( adr ) + drop -2 ( -2 ) + then + ; + : open ( -- okay? ) true ; + : close ( -- ) ; + : install-abort ; + : remove-abort ;
Added: cpu/arm/olpc/1.75/boardgpio.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/boardgpio.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,236 @@ +purpose: Board-specific setup details - pin assigments, etc. + +: set-camera-domain-voltage + aib-unlock + h# d401e80c l@ 4 or ( n ) \ Set 1.8V selector bit in AIB_GPIO2_IO + aib-unlock + h# d401e80c l! +; + +: set-gpio-directions ( -- ) + 3 h# 38 clock-unit-pa + l! \ Enable clocks in GPIO clock reset register + + d# 01 gpio-dir-out \ EN_USB_PWR + d# 04 gpio-dir-out \ COMPASS_SCL + d# 08 gpio-dir-out \ AUDIO_RESET# + d# 10 gpio-dir-out \ LED_STORAGE + d# 11 gpio-dir-out \ VID2 + d# 33 gpio-dir-out \ EN_MSD_PWR + d# 34 gpio-dir-out \ EN_WLAN_PWR + d# 35 gpio-dir-out \ EN_SD_PWR + d# 57 gpio-dir-out \ WLAN_PD# + d# 58 gpio-dir-out \ WLAN_RESET# + d# 73 gpio-dir-out \ CAM_RST + + d# 125 gpio-dir-out \ EC_SPI_ACK + d# 145 gpio-dir-out \ EN_CAM_PWR + d# 146 gpio-dir-out \ HUB_RESET# + d# 151 gpio-dir-out \ DCONLOAD + d# 151 gpio-dir-out \ EC_SPI_CMD + + d# 162 gpio-dir-out \ DCON_SCL + d# 163 gpio-dir-out \ DCON_SDA +; + +create mfpr-table + no-update, \ GPIO_00 - Not connected (TP57) + 0 af, \ GPIO_01 - EN_USB_PWR + no-update, \ GPIO_02 - Not connected (TP54) + no-update, \ GPIO_03 - Not connected (TP53) + 0 af, \ GPIO_04 - COMPASS_SCL (bitbang) + 0 af, \ GPIO_05 - COMPASS_SDA (bitbang) + 0 af, \ GPIO_06 - G_SENSOR_INT + 0 af, \ GPIO_07 - AUDIO_IRQ# + 0 af, \ GPIO_08 - AUDIO_RESET# + 0 af, \ GPIO_09 - COMPASS_INT + 0 af, \ GPIO_10 - LED_STORAGE + 0 af, \ GPIO_11 - VID2 + no-update, \ GPIO_12 - Not connected (TP52) + no-update, \ GPIO_13 - Not connected (TP116) + no-update, \ GPIO_14 - Not connected (TP64) + no-update, \ GPIO_15 - Not connected (TP55) + 0 af, \ GPIO_16 - KEY_IN_1 + 0 af, \ GPIO_17 - KEY_IN_2 + 0 af, \ GPIO_18 - KEY_IN_3 + 0 af, \ GPIO_19 - KEY_IN_4 + 0 af, \ GPIO_20 - KEY_IN_5 + no-update, \ GPIO_21 - Not connected (TP63) + no-update, \ GPIO_22 - Not connected (TP118) + no-update, \ GPIO_23 - Not connected (TP61) + 1 af, \ GPIO_24 - I2S_SYSCLK (Codec) + 1 af, \ GPIO_25 - I2S_BITCLK (Codec) + 1 af, \ GPIO_26 - I2S_SYNC (Codec) + 1 af, \ GPIO_27 - I2S_DATA_OUT (Codec) + 1 af, \ GPIO_28 - I2S_DATA_IN (Codec) + 1 af, \ GPIO_29 - UART1_RXD (debug board) + 1 af, \ GPIO_30 - UART1_TXD (debug board) + 0 af, \ GPIO_31 - SD_CD# (via GPIO) + no-update, \ GPIO_32 - Not connected (TP58) + 0 af, \ GPIO_33 - EN_MSD_PWR + 0 af, \ GPIO_34 - EN_WLAN_PWR + 0 af, \ GPIO_35 - EN_SD_PWR + no-update, \ GPIO_36 - Not connected (TP115) + 1 af, \ GPIO_37 - SDDA_D3 + 1 af, \ GPIO_38 - SDDA_D2 + 1 af, \ GPIO_39 - SDDA_D1 + 1 af, \ GPIO_40 - SDDA_D0 + 1 af, \ GPIO_41 - SDDA_CMD + 1 af, \ GPIO_42 - SDDA_CLK + 3 af, \ GPIO_43 - SPI_MISO (SSP1) (OFW Boot FLASH) + 3 af, \ GPIO_44 - SPI_MOSI + 3 af, \ GPIO_45 - SPI_CLK + 3 af, \ GPIO_46 - SPI_FRM + 3 af, \ GPIO_47 - G_SENSOR_SDL (TWSI6) + 3 af, \ GPIO_48 - G_SENSOR_SDA + no-update, \ GPIO_49 - Not connected (TP62) + no-update, \ GPIO_50 - Not connected (TP114) + no-update, \ GPIO_51 - Not connected (TP59) + no-update, \ GPIO_52 - Not connected (TP113) + 2 af, \ GPIO_53 - RTC_SCK (TWSI2) if R124 populated + 2 af, \ GPIO_54 - RTC_SDA (TWSI2) if R125 populated +\ no-update, \ GPIO_53 - Not connected if nopop R124 to use TWSI6 for RTC +\ no-update, \ GPIO_54 - Not connected if nopop R125 to use TWSI6 for RTC + no-update, \ GPIO_55 - Not connected (TP51) + no-update, \ GPIO_56 - Not connected (TP60) + 0 af, \ GPIO_57 - WLAN_PD# + 0 af, \ GPIO_58 - WLAN_RESET# + + 1 af, \ GPIO_59 - PIXDATA7 + 1 af, \ GPIO_60 - PIXDATA6 + 1 af, \ GPIO_61 - PIXDATA5 + 1 af, \ GPIO_62 - PIXDATA4 + 1 af, \ GPIO_63 - PIXDATA3 + 1 af, \ GPIO_64 - PIXDATA2 + 1 af, \ GPIO_65 - PIXDATA1 + 1 af, \ GPIO_66 - PIXDATA0 + 1 af, \ GPIO_67 - CAM_HSYNC + 1 af, \ GPIO_68 - CAM_VSYNC + 1 af, \ GPIO_69 - PIXMCLK + 1 af, \ GPIO_70 - PIXCLK + + 1 af, \ GPIO_71 - EC_SCL (TWSI3) + 1 af, \ GPIO_72 - EC_SDA + 0 af, \ GPIO_73 - CAM_RST (use as GPIO out) + + 1 af, \ GPIO_74 - GFVSYNC + 1 af, \ GPIO_75 - GFHSYNC + 1 af, \ GPIO_76 - GFDOTCLK + 1 af, \ GPIO_77 - GF_LDE + 1 af, \ GPIO_78 - GFRDATA0 + 1 af, \ GPIO_79 - GFRDATA1 + 1 af, \ GPIO_80 - GFRDATA2 + 1 af, \ GPIO_81 - GFRDATA3 + 1 af, \ GPIO_82 - GFRDATA4 + 1 af, \ GPIO_83 - GFRDATA5 + 1 af, \ GPIO_84 - GFGDATA0 + 1 af, \ GPIO_85 - GFGDATA1 + 1 af, \ GPIO_86 - GFGDATA2 + 1 af, \ GPIO_87 - GFGDATA3 + 1 af, \ GPIO_88 - GFGDATA4 + 1 af, \ GPIO_89 - GFGDATA5 + 1 af, \ GPIO_90 - GFBDATA0 + 1 af, \ GPIO_91 - GFBDATA1 + 1 af, \ GPIO_92 - GFBDATA2 + 1 af, \ GPIO_93 - GFBDATA3 + 1 af, \ GPIO_94 - GFBDATA4 + 1 af, \ GPIO_95 - GFBDATA5 + + no-update, \ GPIO_96 - Not connected (TP112) + + no-update, \ GPIO_97 - Not connected (R100 nopop) if we use TWSI2 for RTC + no-update, \ GPIO_98 - Not connected (R106 nopop) if we use TWSI2 for RTC +\ 2 af, \ GPIO_97 - RTC_SCK (TWSI6) if R100 populated +\ 2 af, \ GPIO_98 - RTC_SDA (TWSI6) if R106 populated + + 0 af, \ GPIO_99 - TOUCH_SCR_INT + 0 af, \ GPIO_100 - DCONSTAT0 + 0 af, \ GPIO_101 - DCONSTAT1 + + no-update, \ GPIO_102 - (USIM_CLK) - Not connected (TP48) + no-update, \ GPIO_103 - (USIM_IO) - Not connected (TP50) + + 0 af, \ GPIO_104 - ND_IO[7] + 0 af, \ GPIO_105 - ND_IO[6] + 0 af, \ GPIO_106 - ND_IO[5] + 0 af, \ GPIO_107 - ND_IO[4] + + 1 af, \ GPIO_108 - CAM_SDL - Use as GPIO, bitbang + 1 af, \ GPIO_109 - CAM_SDA - Use as GPIO, bitbang + + 1 af, \ GPIO_110 - (ND_IO[13]) - Not connected (TP43) + 1 af, \ GPIO_111 - (ND_IO[8]) - Not connected (TP108) + 0 af, \ GPIO_112 - ND_RDY[0] + 3 af, \ GPIO_113 - (SM_RDY) - MSD_CMD + 1 af, \ GPIO_114 - G_CLK_OUT - Not connected (TP93) + + 4 af, \ GPIO_115 - UART3_TXD (J4) + 4 af, \ GPIO_116 - UART3_RXD (J4) + 3 af, \ GPIO_117 - UART4_RXD - Not connected (TP117) + 3 af, \ GPIO_118 - UART4_TXD - Not connected (TP56) + 3 af, \ GPIO_119 - SDI_CLK (SSP3) + 3 af, \ GPIO_120 - SDI_CS# + 3 af, \ GPIO_121 - SDI_MOSI + 3 af, \ GPIO_122 - SDI_MISO + + 3 af, \ GPIO_123 - 32 KHz_CLK_OUT - Not connected (TP92) + + 0 af, \ GPIO_124 - DCONIRQ + 0 af, \ GPIO_125 - EC_SPI_ACK + + 3 af, \ GPIO_126 - MSD_DATA2 + 3 af, \ GPIO_127 - MSD_DATA0 + 0 af, \ GPIO_128 - EB_MODE# + 0 af, \ GPIO_129 - LID_SW# + 3 af, \ GPIO_130 - MSD_DATA3 + 1 af, \ GPIO_131 - SD_DATA3 + 1 af, \ GPIO_132 - SD_DATA2 + 1 af, \ GPIO_133 - SD_DATA1 + 1 af, \ GPIO_134 - SD_DATA0 + 3 af, \ GPIO_135 - MSD_DATA1 + 1 af, \ GPIO_136 - SD_CMD + no-update, \ GPIO_137 - Not connected (TP111) + 3 af, \ GPIO_138 - MSD_CLK + 1 af, \ GPIO_139 - SD_CLK + no-update, \ GPIO_140 - Not connected if R130 is nopop +\ 1 af, \ GPIO_140 - (SD_CD# if R130 is populated) + 1 af, \ GPIO_141 - SD_WP + + no-update, \ GPIO_142 - (USIM_RSTn) - Not connected (TP49) + 0 af, \ GPIO_143 - ND_CS0# + 0 af, \ GPIO_144 - ND_CS1# + 1 af, \ GPIO_145 - EN_CAM_PWR + 1 af, \ GPIO_146 - HUB_RESET# + + 0 af, \ GPIO_147 - ND_WE_N + 0 af, \ GPIO_148 - ND_RE_N + 0 af, \ GPIO_149 - ND_CLE + 0 af, \ GPIO_150 - ND_ALE + 1 af, \ GPIO_151 - DCONLOAD + 1 af, \ GPIO_152 - (SM_BELn) - Not connected (TP40) + 1 af, \ GPIO_153 - (SM_BEHn) - Not connected (TP105) + 0 af, \ GPIO_154 - (SM_INT) - EC_IRQ# + 1 af, \ GPIO_155 - (EXT_DMA_REQ0) - EC_SPI_CMD + no-update, \ GPIO_156 - PRI_TDI (JTAG) + no-update, \ GPIO_157 - PRI_TDS (JTAG) + no-update, \ GPIO_158 - PRI_TDK (JTAG) + no-update, \ GPIO_159 - PRI_TDO (JTAG) + 0 af, \ GPIO_160 - ND_RDY[1] + 1 af, \ GPIO_161 - ND_IO[12] - Not connected (TP 44) + 1 af, \ GPIO_162 - (ND_IO[11]) - DCON_SCL + 1 af, \ GPIO_163 - (ND_IO[10]) - DCON_SDA + 1 af, \ GPIO_164 - (ND_IO[9]) - Not connected (TP106) + 0 af, \ GPIO_165 - ND_IO[3] + 0 af, \ GPIO_166 - ND_IO[2] + 0 af, \ GPIO_167 - ND_IO[1] + 0 af, \ GPIO_168 - ND_IO[0] + +: init-mfprs + d# 169 0 do + mfpr-table i wa+ w@ ( code ) + dup 8 = if ( code ) + drop ( ) + else ( code ) + i af! ( ) + then + loop +;
Added: cpu/arm/olpc/1.75/build/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/build/Makefile Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,64 @@ +ROMNAME=ofw + +BASEDIR= `(cd ../../../../..; pwd;)` + +OS := $(shell uname) +HOSTCPU= $(shell ${BASEDIR}/forth/lib/hostcpu.sh) +HOSTDIR= ../../../../${HOSTCPU}/${OS} +BUILDSH= ${BASEDIR}/forth/lib/build.sh + +TAGFILES= ../../../build/*.tag *.tag +CLIENTDIR=../../../../../clients +CLIENTPROGS= + +all: ${ROMNAME}.rom tags + +${ROMNAME}.tag: ${ROMNAME}.rom + +tags: ${ROMNAME}.tag + @${BASEDIR}/forth/lib/toctags ${BASEDIR} ${TAGFILES} + +${ROMNAME}.rom: FORCE build ${CLIENTPROGS} ${HOSTDIR}/forth + ./build $@ + +${HOSTDIR}/forth: + @make -C ${HOSTDIR} forth + +../../build/inflate.bin: + @make -C ../../build inflate.bin + +build: + @ln -sf ${BUILDSH} build + +clean: + rm -f *.dic *.log headers *~ *.elf *.di *.img builton.fth build *.rom *.version tags *.tag + +clean-all: clean + @make -C ../../build clean + @make -C ${HOSTDIR} clean + +.PHONY: FORCE clean all clean-all + +# LICENSE_BEGIN +# Copyright (c) 2009 FirmWorks +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# LICENSE_END
Added: cpu/arm/olpc/1.75/devices.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/devices.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,175 @@ +fload ${BP}/dev/omap/diaguart.fth \ OMAP UART +h# d4030000 to uart-base \ UART# base address on MMP2 +d# 26000000 to uart-clock-frequency + +: init-clocks + -1 h# d4051024 l! \ PMUM_CGR_PJ - everything on + h# 07 h# d4015064 l! \ APBC_AIB_CLK_RST - reset, functional and APB clock on + h# 03 h# d4015064 l! \ APBC_AIB_CLK_RST - release reset, functional and APB clock on + h# 13 h# d401502c l! \ APBC_UART1_CLK_RST - VCTCXO, functional and APB clock on (26 mhz) + h# 13 h# d4015034 l! \ APBC_UART3_CLK_RST - VCTCXO, functional and APB clock on (26 mhz) + h# c1 h# d401e0c8 l! \ GPIO29 = af1 for UART1 RXD + h# c1 h# d401e0cc l! \ GPIO30 = af1 for UART1 TXD + h# c4 h# d401e260 l! \ GPIO115 = af4 for UART3 RXD + h# c4 h# d401e264 l! \ GPIO116 = af4 for UART3 TXD + h# 1b h# d4282854 l! \ SD0 clocks +; + +: inituarts ( -- ) + init-clocks + + h# 40 1 uart! \ Marvell-specific UART Enable bit + 3 3 uart! \ 8 bits, no parity + 7 2 uart! \ Clear and enable FIFOs + d# 38400 baud +; + +fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART + +0 value keyboard-ih +0 value screen-ih + +fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device + +\ Install the simple UART driver from the standalone I/O init chain +warning off +: stand-init-io ( -- ) + stand-init-io + inituarts install-uart-io + ." UART installed" cr +; +warning on + +\ Create a pseudo-device that presents the dropin modules as a filesystem. +fload ${BP}/ofw/fs/dropinfs.fth + +\ This devalias lets us say, for example, "dir rom:" +devalias rom /dropin-fs + +fload ${BP}/cpu/arm/mmp2/timer.fth +fload ${BP}/cpu/arm/mmp2/twsi.fth +fload ${BP}/cpu/arm/mmp2/mfpr.fth +fload ${BP}/cpu/arm/mmp2/gpio.fth + +fload ${BP}/cpu/arm/olpc/1.75/boardtwsi.fth +fload ${BP}/cpu/arm/olpc/1.75/boardgpio.fth +: init-stuff + set-camera-domain-voltage + acgr-clocks-on + init-mfprs + set-gpio-directions + init-timers + init-twsi + power-on-dsi + power-on-sd +; +stand-init: + init-stuff +; + +fload ${BP}/cpu/arm/mmp2/irq.fth + +fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer + +0 0 " d4030000" " /" begin-package \ UART1 + fload ${BP}/cpu/arm/mmp2/uart.fth +end-package +devalias com1 /uart +: com1 " com1" ; +' com1 is fallback-device + +0 0 " d4018000" " /" begin-package \ UART3 + fload ${BP}/cpu/arm/mmp2/uart.fth +end-package +devalias com2 /uart +: com2 " com2" ; + +0 0 " d420b000" " /" begin-package + " display" name + fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth +\ fload ${BP}/cpu/arm/mmp2/dsi.fth + + fload ${BP}/cpu/arm/mmp2/lcd.fth + : display-on + init-lcd + fb-pa hdisp vdisp * >bytes h# ff fill + ; + : map-frame-buffer ( -- ) + fb-pa to frame-buffer-adr + ; + " display" device-type + " ISO8859-1" encode-string " character-set" property + 0 0 encode-bytes " iso6429-1983-colors" property + + : display-install ( -- ) + display-on + default-font set-font + map-frame-buffer + width height ( width height ) + over char-width / over char-height / ( width height rows cols ) + /scanline depth fb-install ( ) + ; + + : display-remove ( -- ) ; + : display-selftest ( -- failed? ) false ; + + ' display-install is-install + ' display-remove is-remove + ' display-selftest is-selftest +end-package +devalias screen /display + +devalias keyboard /keyboard + +fload ${BP}/ofw/termemu/cp881-16.fth + +fload ${BP}/cpu/arm/mmp2/sdhcimmp2.fth + +devalias ext /sd/disk@1 + +fload ${BP}/dev/olpc/kb3700/spicmd.fth + +0 0 " d4208000" " /" begin-package \ USB Host Controller + h# 200 constant /regs + my-address my-space /regs reg + : my-map-in ( len -- adr ) + my-space swap " map-in" $call-parent h# 100 + ( adr ) + 3 over h# a8 + rl! ( adr ) \ Force host mode + ; + : my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ; + false constant has-dbgp-regs? + false constant needs-dummy-qh? + false constant grab-controller + fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth +end-package + +: usb-power-on ( -- ) d# 82 gpio-set ; \ 1 instead of 82 for XO + +fload ${BP}/cpu/arm/marvell/utmiphy.fth +stand-init: Init USB Phy + init-usb-phy +; + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/arm/olpc/1.75/dram-forth.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/dram-forth.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,57 @@ +\ Generate an XDB (Marvell Extreme Debugger) script from DRAM setup info + +0 value this-reg-xt +0 value this-reg-adr +0 value this-reg-value +: note-mem-reg ( apf -- ) + dup body> to this-reg-xt + @ +mem-ctrl to this-reg-adr + 0 to this-reg-value +; +' note-mem-reg to do-mem-reg + +: (do-bits) ( value start #bits -- ) + drop lshift this-reg-value or to this-reg-value +; +' (do-bits) to do-bits + +: .xl ( n -- ) + push-hex + <# u# u# u# u# u# u# u# u# u#> 2dup type + pop-base +; +: xdb-outbits ( -- ) + 3 spaces + this-reg-value .xl + space + this-reg-adr .xl + ." l! \ " + this-reg-xt >name name>string type + cr +; +' xdb-outbits to outbits + +: show-auto-cal ( -- ) +; + +: wait-dram-init ( -- ) + cr + ." begin h# d00001b0 l@ 1 and until" cr + cr +; + +: wait-tzqinit ( -- ) ; + +: do-dummy-reads ( -- ) + ." d# 131 0 do 0 l@ drop loop \ dummy reads" cr +; + +: show-dll-delay ( -- ) + ." ."" DLL_DELAY from PHY_CTRL_14: "" d0000240 l@ 8 rshift h# ff and .x cr" cr +; +: start-dram-init ( -- ) + ." : init-dram" cr +; +: end-dram-init ( -- ) + ." ;" cr +;
Added: cpu/arm/olpc/1.75/draminit.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/draminit.bth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,9 @@ +purpose: Build Open Firmware for Marvell MMP2 +\ See license at end of file + +command: &builder &this +build-now + +fload ../dram.fth +fload ../dram-forth.fth +fload ../xo-dram.fth
Added: cpu/arm/olpc/1.75/lcdcfg.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/lcdcfg.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,24 @@ +d# 4 value hsync +d# 1200 value hdisp +d# 1456 value htotal .( HTOTAL ???) cr +d# 212 value hbp + +d# 4 value vsync +d# 800 value vdisp +d# 845 value vtotal .( VTOTAL ???) cr +d# 31 value vbp + +: hfp ( -- n ) htotal hdisp - hsync - hbp - ; +: vfp ( -- n ) vtotal vdisp - vsync - vbp - ; + +2 constant #lanes +3 constant bytes/pixel +d# 24 constant bpp + +: >bytes ( pixels -- chunks ) bytes/pixel * ; +: >chunks ( pixels -- chunks ) >bytes #lanes / ; + +alias width hdisp +alias height vdisp +alias depth bpp +width >bytes constant /scanline
Added: cpu/arm/olpc/1.75/sp.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/sp.bth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,397 @@ +purpose: Load file for ARM Forth kernel +\ See license at end of file + +command: &builder &this +build-now + +[ifndef] arm-assembler \ Make sure we have the ARM assembler +only forth also definitions + +fload ${BP}/forth/lib/bitops.fth +\needs set-relocation-bit defer set-relocation-bit \ keep init-assem happy + +\ only forth also meta also definitions + +fload ${BP}/cpu/arm/assem.fth +fload ${BP}/cpu/arm/code.fth + +[then] +: assembler ( -- ) arm-assembler ; +: setreg \ reg value ( -- ) + safe-parse-word $hnumber abort" Bad number" + safe-parse-word $hnumber abort" Bad number" + swap + " set r1,``" evaluate + " set r0,``" evaluate + " str r0,[r1]" evaluate +; +: getreg \ reg ( -- ) + safe-parse-word $hnumber abort" Bad number" + " set r1,``" evaluate + " ldr r0,[r1]" evaluate +; +: putreg \ reg ( -- ) + " str r0,[r1]" evaluate +; +: bitset \ reg ( -- ) + safe-parse-word $hnumber abort" Bad number" + " orr r0,r0,``" evaluate +; +: bitclr \ reg ( -- ) + safe-parse-word $hnumber abort" Bad number" + " bic r0,r0,``" evaluate +; + +label unreset + \ From jasper.c + setreg d4051024 ffffffff \ PMUM_CGR_PJ - Clocks on + + setreg D42828dc 1FFFF \ PMUA_GLB_CLK_CTRL - Enable CLK66 to APB, PLL2/12/6/3/16/8/4/2/1, PLL1/12/6/3/16/8/4 + + setreg D4015064 07 \ AIB clock + setreg D4015064 03 \ AIB clock + + setreg D401502c 13 \ UART1 clk - 26 MHz + setreg D4015034 13 \ UART3 clk - 26 MHz + + getreg D401E160 \ G_CLK_REQ + bitset 4000 \ Enable pullup + putreg + + setreg D4015000 83 \ APBC_RTC_CLK_RST - Enable RTC clock and power + + setreg D4015024 05 \ APBC_TIMERS1_CLK_RST - Reset + setreg D4015024 33 \ APBC_TIMERS1_CLK_RST - Enable Timers at 26 MHz + + getreg d4282c08 \ SCU_PJ4_CPU_CONF + bitset 40 \ Bit 6 - bypass clock gate + bitset 200 \ Bit 9 - allow CPU in WFI to be woken up by Multi-ICE as well as by interrupt + bitset 2000 \ Bit 13 - disable MMU translation abort for L2 cache + bitset 4000 \ Bit 14 - bypass clock gate in L2 cache + bitset 80000 \ Bit 19 - L2 Cache burst 8 enable + bitclr 800000 \ Bit 23 - use slow queue for CPU to DDR access + putreg + + \ Now change the frequency + \ from freq_ll.S + + set r4, 0xd0000000 \ DMEM base address + set r5, 0xd4050000 \ PMUM base address + set r6, 0xd4282800 \ PMUA base address + + set r7, 0xffffffff \ All clocks ON + str r7, [r5, #0x0024] \ PMUM_CGR_SP + set r7, 0x00061808 \ Reserved bits, but supposed to "allow freq" + str r7, [r6, #0x88] \ PMUA_DEBUG + + \ change to PLL1/2 first, start-up operation point + set r7, 0x00000000 + str r7, [r5, #0x8] + set r7, 0x08fd96d9 + str r7, [r6, #0x00] + set r7, 0x78fd96d9 + str r7, [r6, #0x04] + + \ select PLL2 frequency, 520MHz + set r7, 0x08600322 \ Bandgap+charge pump+VCO loading+regulator defaults, 486.3-528.55 PLL2 (bits 10:6) + str r7, [r5, #0x0414] \ PMUM_PLL2_CTRL1 + set r7, 0x00FFFE00 \ refclk divisor and feedback divisors at max, software controls activation + str r7, [r5, #0x0034] \ PMUM_PLL2_CTRL2 + set r7, 0x0021da00 \ refclk divisor=4, feedback divisor=0x76=118, software controls activation + str r7, [r5, #0x0034] \ PMUM_PLL2_CTRL1 + set r7, 0x0021db00 \ same plus enable + str r7, [r5, #0x0034] \ PMUM_PLL2_CTRL2 + set r7, 0x28600322 \ same as above plus release PLL loop filter + str r7, [r5, #0x0414] \ PMUM_PLL2_CTRL1 + \ select clock source, PJ4-PLL1, SP-PLL1/2, AXI/DDR-PLL1 + set r7, 0x20800000 \ PLL1 > PJ4 (bits 31:29), PLL1/2 > SP (bits 28:26), PLL1 > AXI&DDR (bits 25:23) + str r7, [r5, #0x0008] \ PMUM_FCCR + \ divider setting and frequency change request, core-800, ddr-400, axi-200 + set r7, 0x08fd8248 \ speed change voting, ACLK:3, DCLK:0, BACLK1:1, PCLK:0 + str r7, [r6, #0x00] \ PMUA_CC_SP + set r7, 0x78fd8248 \ etc - hard to decipher + str r7, [r6, #0x04] \ PMUA_CC_PJ + + \ DDR recalibration after frequency change + \ CONFIG_DECODE_ADDR + set r7, 0xD0004D56 + str r7, [r4, #0x010] + + \ This is for Elpida DDR2 512M + \ MMAP + set r7, 0x000C0001 + str r7, [r4, #0x100] + set r7, 0x100C0001 + str r7, [r4, #0x110] + + \ CONFIG_TYPE + set r7, 0x00006420 + str r7, [r4, #0x020] + set r7, 0x00006420 + str r7, [r4, #0x030] + set r7, 0x00000000 + str r7, [r4, #0xB40] + set r7, 0x00000000 + str r7, [r4, #0xB50] + + \ TIMING + set r7, 0x4CDA00C5 + str r7, [r4, #0x050] + set r7, 0x94860342 + str r7, [r4, #0x060] + set r7, 0x2000381B + str r7, [r4, #0x190] + set r7, 0x3023009D + str r7, [r4, #0x1C0] + set r7, 0x00110142 + str r7, [r4, #0x650] + set r7, 0x02424190 + str r7, [r4, #0x660] + \ End of Elpida-specific stuff + + \ CTRL + set r7, 0x00005000 + str r7, [r4, #0x080] + set r7, 0x00080010 + str r7, [r4, #0x090] + set r7, 0xC0000000 + str r7, [r4, #0x0F0] + set r7, 0x20C08115 + str r7, [r4, #0x1A0] + set r7, 0x01010101 + str r7, [r4, #0x280] + set r7, 0x00000000 + str r7, [r4, #0x760] + set r7, 0x03000000 + str r7, [r4, #0x770] + set r7, 0x00000133 + str r7, [r4, #0x780] + set r7, 0x01010101 + str r7, [r4, #0x7B0] + set r7, 0x0000000F + str r7, [r4, #0x7D0] + set r7, 0x00000000 + str r7, [r4, #0x7E0] + + \ MCB + set r7, 0x00000000 + str r7, [r4, #0x540] + set r7, 0x00000001 + str r7, [r4, #0x570] + set r7, 0x00000000 + str r7, [r4, #0x580] + set r7, 0x00000000 + str r7, [r4, #0x590] + set r7, 0x00000000 + str r7, [r4, #0x5A0] + set r7, 0x00000000 + str r7, [r4, #0x5B0] + + \ WRITE_PROTECTION + set r7, 0x00000000 + str r7, [r4, #0x180] + + \ __PHY Deskew PLL config and PHY initialization + set r7, 0x00000000 + str r7, [r4, #0x210] + set r7, 0x80000000 + str r7, [r4, #0x240] + + \ DLL reset, Need this after any DCLK freq change + set r8, 0x20000000 + ldr r7, [r4, #0x240] + orr r7, r7, r8 + str r7, [r4, #0x240] + set r8, 0xdFFFFFFF + ldr r7, [r4, #0x240] + and r7, r7, r8 + str r7, [r4, #0x240] + + \ Pad drive strength auto calibration + set r8, 0x00110000 + ldr r7, [r4, #0x200] + orr r7, r7, r8 + str r7, [r4, #0x200] + ldr r7, [r4, #0x240] + set r8, 0xFFFeFFFF + ldr r7, [r4, #0x200] + and r7, r7, r8 + str r7, [r4, #0x200] + + \ Elpida DDR2 512M-specific + set r7, 0x20004444 + str r7, [r4, #0x140] + set r7, 0x13300559 + str r7, [r4, #0x1D0] + set r7, 0x03300990 + str r7, [r4, #0x1E0] + set r7, 0x00000077 + str r7, [r4, #0x1F0] + \ End of Elpida-specific + + set r7, 0x20000088 + str r7, [r4, #0x230] + set r7, 0x00000080 + str r7, [r4, #0xE10] + set r7, 0x00000080 + str r7, [r4, #0xE20] + set r7, 0x00000080 + str r7, [r4, #0xE30] + + set r7, 0x00000000 + str r7, [r4, #0xE40] + set r7, 0x00000000 + str r7, [r4, #0xE50] + + \ initialize LPDDR2 + set r7, 0x03000001 + str r7, [r4, #0x120] + ldr r7, [r4, #0x1B0] + set r7, 0x0302003F + str r7, [r4, #0x410] + set r7, 0x01001000 + str r7, [r4, #0x120] + set r7, 0x02001000 + str r7, [r4, #0x120] + set r7, 0x03020001 + str r7, [r4, #0x410] + set r7, 0x03020002 + str r7, [r4, #0x410] + set r7, 0x03020003 + str r7, [r4, #0x410] + +\ End of frequency change + + setreg d4282110 0 \ Release global IRQ0 mask + + setreg d4283894 11000008 \ DFI chip select timing configuration for CS1 + + setreg d428290c 600 \ Power up audio module + setreg d428290c 610 \ and enable peripheral clock + setreg d428290c 710 \ and disable isolation + setreg d428290c 712 \ and release reset + + setreg d4050040 d0080040 \ I2S0 SYSCLK_EN, PLL1/2, denom=0x10, numerator=0x40 + setreg d4050044 d0040040 \ I2S0 SYSCLK_EN, PLL1/2, denom=0x08, numerator=0x40 + + setreg d42a0c3c 10800 \ Undocumented register in SSPA + setreg d42a0c34 211921 \ Undocumented register in SSPA + + setreg d428285c 08 \ Enable AXI clock to USB + setreg d428285c 09 \ and release from reset + + setreg d42828f8 18 \ Enable HSIC1 SPH Controller Clock and AXI Clock + setreg d42828f8 1b \ and release from reset + + setreg d42828fc 18 \ Undocumented, probably another USB HSIC + setreg d42828fc 1b \ Undocumented .. + + setreg d4282900 18 \ Enable FSIC SPH Controller Clock and AXI Clock + setreg d4282900 1b \ and release from reset + + setreg d4282848 08 \ Enable AXI clock to IRE + setreg d4282848 09 \ and release from reset + + setreg D4015004 03 \ Enable TWSI1 clk + \ Delay 99999 + + setreg d4282854 1b \ Enable SDHC0 clk + setreg d42828e8 1b \ Enable SDHC3 clk + + getreg d42828a4 \ Vmeta + bitset 400 \ Module powered up + bitclr 200 \ Inputs isolated + putreg + bitset 008 \ AXI clock enabled + putreg + bitset 001 \ AXI released from reset + putreg + bitset 010 \ Peripheral clock enabled + putreg + bitset 002 \ Peripheral released from reset + putreg + bitset 020 \ PLL2/3 + putreg + bitset 004 \ Reserved + putreg + bitset 100 \ Isolation disabled + putreg + bitclr 240 \ Input isolation disabled, (bit 6 is part of the clock select field) + putreg + \ Whew, that was tedious + + setreg d428284c 08 \ PMUA_DISPLAY1_CLK_RES_CTL - AXI Clk enabled + setreg d428284c 09 \ plus AXI released from reset + setreg d428284c 19 \ plus peripheral clock enabled + setreg d428284c 1b \ plus peripheral released from reset + + setreg d4015038 03 \ Use 32 kHz clock input (bit 1 reserved) + +\ mrc p15,0,r0,c1,c0,2 +\ orr r0,r0,#0xf \ Enable MMX +\ mcr p15,0,r0,c1,c0,2 + +\ Allow access of performance counters (PMU) from user space +\ mov r0, #0x1 +\ mrc p15, 0, r0, c9, c14, 0 +\ orr r0, r0, #0x1 +\ mcr p15, 0, r0, c9, c14, 0 + +\ Ensure branch prediction is enabled - BPU (Default) +\ mrc p15, 0, r0, c1, c0, 0 +\ orr r0, r0, #0x800 +\ mcr p15, 0, r0, c1, c0, 0 + +\ setreg d4015064 03 \ AIB clock, redundant with above + +\ //BU_REG_WRITE( SMC_CSDFICFGX, 0x51890009 ); // SMC_CSDFICFG0 +\ //BU_REG_WRITE( SMC_CSADRMAPX, 0x10000F00 ); // SMC_CSADRMAP0 +\ //BU_REG_WRITE(0xd4283824, 0xC6CFF2C9 ); +\ setreg d4283894 11000008 \ DFI, redundant with above + +\ setreg d4015000 83 \ RTC, redundant with above + setreg d4015074 03 \ MPMU, clocks on + setreg d4282864 09 \ DMA enabled and release from reset + setreg d4282860 b8 \ NAND FLASH PLL1/8 + ECC PLL1/4, AXI clock enabled + setreg d4282860 bf \ plus ECC&controller&AXI released from reset + +\ Finally, release the reset for the main CPU + + set r0,0xd4050020 + ldr r1,[r0] + bic r1,r1,#2 + str r1,[r0] + + begin + mcr p15,0,r0,cr7,cr0,4 \ Wait For Interrupt + again + +end-code + +writing sp.img + unreset here over - ofd @ fputs +ofd @ fclose + +\ LICENSE_BEGIN +\ Copyright (c) 2008 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: cpu/arm/olpc/1.75/xo-dram.fth ============================================================================== --- cpu/arm/olpc/1.75/xo-dram.fth Mon Oct 18 05:25:53 2010 (r1986) +++ cpu/arm/olpc/1.75/xo-dram.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -73,6 +73,8 @@ \ tCKSRE max(5nCK, 10ns) \ tCKSRX max(5nCK, 10ns)
+start-dram-init + mmap0 h# 0000.0000 d# 23 rshift start-addr h# 4000.0000 log2 d# 16 - area-length @@ -554,3 +556,5 @@ do-dummy-reads
show-dll-delay + +end-dram-init
Modified: dev/usb2/hcd/ehci/ehci.bth ============================================================================== --- dev/usb2/hcd/ehci/ehci.bth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/ehci/ehci.bth Mon Oct 18 06:02:38 2010 (r1987) @@ -11,6 +11,7 @@
" ehci" encode-string " device_type" property
+fload ${BP}/dev/usb2/hcd/ehci/pci.fth fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
end0
Modified: dev/usb2/hcd/ehci/ehci.fth ============================================================================== --- dev/usb2/hcd/ehci/ehci.fth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/ehci/ehci.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -12,24 +12,11 @@ 0 value ehci-reg 0 value op-reg-offset
-h# 100 constant /regs - -\ Configuration space registers -my-address my-space encode-phys - 0 encode-int encode+ 0 encode-int encode+ -\ EHCI operational registers -0 0 my-space 0200.0010 + encode-phys encode+ - 0 encode-int encode+ /regs encode-int encode+ -" reg" property - : map-regs ( -- ) - 4 my-w@ h# 16 or 4 my-w! \ memory write and invalidate, bus master, mem - 0 0 my-space h# 0200.0010 + /regs map-in to ehci-reg + /regs my-map-in to ehci-reg ; : unmap-regs ( -- ) - \ Don't disable because somebody else might be using the controller. - \ 4 my-w@ 7 invert and 4 my-w! - ehci-reg /regs map-out 0 to ehci-reg + ehci-reg /regs my-map-out 0 to ehci-reg ;
: ehci-reg@ ( idx -- data ) ehci-reg + rl@ ; @@ -101,23 +88,14 @@ 0 value dbgp-offset 0 value dbgp-bar
-: find-dbgp-regs ( -- ) - h# 34 my-l@ ( capability-ptr ) - begin dup while ( cap-offset ) - dup my-b@ h# 0a = if ( cfg-adr ) - 2+ my-w@ ( dbgp-ptr ) - dup h# 1fff and to dbgp-offset ( ) - d# 13 rshift 7 and 1- /l* h# 10 + to dbgp-bar - exit - then ( cfg-adr ) - 1+ my-b@ ( cap-offset' ) - repeat ( cap-offset ) - drop -; : debug-port-active? ( -- flag ) hcsparams@ h# f0.0000 and 0= if false exit then - find-dbgp-regs - dbgp-offset 0= if false exit then + has-dbgp-regs? if ( offset bar ) + to dbgp-bar to dbgp-offset + else ( ) + false exit + then + \ We should take dbgp-bar into account, but for now we \ just assume it's the same BAR as for the main registers. dbgp-offset ehci-reg@
Modified: dev/usb2/hcd/ehci/pci.fth ============================================================================== --- dev/usb2/hcd/ehci/pci.fth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/ehci/pci.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -1,16 +1,67 @@ +h# 100 constant /regs + \ Configuration space registers my-address my-space encode-phys 0 encode-int encode+ 0 encode-int encode+ + \ EHCI operational registers 0 0 my-space 0200.0010 + encode-phys encode+ -0 encode-int encode+ h# 100 encode-int encode+ +0 encode-int encode+ /regs encode-int encode+ " reg" property
+: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ; +: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ; + +: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ; +: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ; + +: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ; +: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ; + : my-map-in ( len -- adr ) >r 0 0 my-space h# 0200.0010 + r> " map-in" $call-parent 4 my-w@ h# 16 or 4 my-w! \ Set MWI, bus mastering, and mem enable ; : my-map-out ( adr len -- ) - 4 my-w@ 7 invert and 4 my-w! + \ Don't disable because somebody else might be using the controller. + \ 4 my-w@ 7 invert and 4 my-w! " map-out" $call-parent ; + +: has-dbgp-regs? ( -- false | offset bar true) + h# 34 my-l@ ( capability-ptr ) + begin dup while ( cap-offset ) + dup my-b@ h# 0a = if ( cfg-adr ) + 2+ my-w@ ( dbgp-ptr ) + dup h# 1fff and ( offset ) + d# 13 rshift 7 and 1- /l* h# 10 + ( offset bar ) + true ( offset bar true ) + exit + then ( cfg-adr ) + 1+ my-b@ ( cap-offset' ) + repeat ( cap-offset ) + drop false ( false ) +; +: needs-dummy-qh? ( -- flag ) 0 my-w@ h# 1106 ( VIA ) = ; +: grab-controller ( -- error? ) + hccparams@ 8 rshift h# ff and dup if ( config-adr ) + dup my-l@ h# 10001 = if ( config-adr ) + h# 100.0000 over my-l! ( config-adr ) \ Ask for it + true ( config-adr error? ) + d# 100 0 do ( config-adr error? ) + over my-l@ h# 101.0000 and h# 100.0000 = if + \ Turn off SMIs in Legacy Support Extended CSR + h# e000.0000 h# 6c my-l! ( config-adr error? ) + 0 my-l@ h# 27cc8086 = if + h# ffff.0000 h# 70 my-l! \ Clear EHCI Intel special SMIs + then + 0= leave ( config-adr error?' ) + then ( config-adr error? ) + d# 10 ms ( config-adr error? ) + loop ( config-adr error? ) + nip exit + then ( config-adr ) + then ( config-adr ) + drop ( ) + false +;
Modified: dev/usb2/hcd/ehci/probe.fth ============================================================================== --- dev/usb2/hcd/ehci/probe.fth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/ehci/probe.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -51,29 +51,6 @@ dup portsc@ swap portsc! ( ) \ Clear connection change bit ;
-: grab-controller ( -- error? ) - hccparams@ 8 rshift h# ff and dup if ( config-adr ) - dup my-l@ h# 10001 = if ( config-adr ) - h# 100.0000 over my-l! ( config-adr ) \ Ask for it - true ( config-adr error? ) - d# 100 0 do ( config-adr error? ) - over my-l@ h# 101.0000 and h# 100.0000 = if - \ Turn off SMIs in Legacy Support Extended CSR - h# e000.0000 h# 6c my-l! ( config-adr error? ) - 0 my-l@ h# 27cc8086 = if - h# ffff.0000 h# 70 my-l! \ Clear EHCI Intel special SMIs - then - 0= leave ( config-adr error?' ) - then ( config-adr error? ) - d# 10 ms ( config-adr error? ) - loop ( config-adr error? ) - nip exit - then ( config-adr ) - then ( config-adr ) - drop ( ) - false -; - : probe-setup ( -- ) \ Set active-package so device nodes can be added and removed my-self ihandle>phandle push-package
Modified: dev/usb2/hcd/ehci/qhtd.fth ============================================================================== --- dev/usb2/hcd/ehci/qhtd.fth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/ehci/qhtd.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -633,8 +633,9 @@ dummy-qh ?dup if free-qh 0 to dummy-qh then ;
+ : ?alloc-dummy-qh ( -- ) - 0 my-w@ h# 1106 ( VIA ) = if alloc-dummy-qh then + needs-dummy-qh? if alloc-dummy-qh then ;
\ The words this calls are written so they can be called again
Modified: dev/usb2/hcd/hcd.fth ============================================================================== --- dev/usb2/hcd/hcd.fth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/hcd.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -58,18 +58,6 @@ \ Common routines \ ---------------------------------------------------------------------------
-: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ; -: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ; - -: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ; -: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ; - -: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ; -: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ; - -: map-in ( phys.lo,md,hi len -- vaddr ) " map-in" $call-parent ; -: map-out ( vaddr size -- ) " map-out" $call-parent ; - \ XXX Room for improvement: keep tab of hcd-map-in's to improve performance. : hcd-map-in ( virt size -- phys ) false dma-map-in ; : hcd-map-out ( virt phys size -- ) dma-map-out ;
Added: dev/usb2/hcd/uhci/pci.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ dev/usb2/hcd/uhci/pci.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -0,0 +1,32 @@ +h# 400 constant /regs + +\ Configuration space registers +my-address my-space encode-phys + 0 encode-int encode+ 0 encode-int encode+ +\ UHCI operational registers +0 0 my-space 0100.0020 + encode-phys encode+ + 0 encode-int encode+ h# 400 encode-int encode+ +" reg" property + +: my-b@ ( offset -- b ) my-space + " config-b@" $call-parent ; +: my-b! ( b offset -- ) my-space + " config-b!" $call-parent ; + +: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ; +: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ; + +: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ; +: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ; + +: my-map-in ( len -- adr ) + >r + 0 0 my-space h# 0100.0020 + r> " map-in" $call-parent ( adr ) + 4 my-w@ h# 17 or 4 my-w! ( adr ) +; +: my-map-out ( adr len -- ) + 4 my-w@ 7 invert and 4 my-w! ( adr len ) + " map-out" $call-parent ( ) +; + +: ?disable-smis ( -- ) + 0 my-l@ h# 27c88086 = if h# af00 h# 80 my-w! then +;
Modified: dev/usb2/hcd/uhci/uhci.bth ============================================================================== --- dev/usb2/hcd/uhci/uhci.bth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/uhci/uhci.bth Mon Oct 18 06:02:38 2010 (r1987) @@ -11,6 +11,7 @@
" uhci" encode-string " device_type" property
+fload ${BP}/dev/usb2/hcd/uhci/pci.fth fload ${BP}/dev/usb2/hcd/uhci/loadpkg.fth
end0
Modified: dev/usb2/hcd/uhci/uhci.fth ============================================================================== --- dev/usb2/hcd/uhci/uhci.fth Mon Oct 18 05:25:53 2010 (r1986) +++ dev/usb2/hcd/uhci/uhci.fth Mon Oct 18 06:02:38 2010 (r1987) @@ -10,24 +10,10 @@ 0 value open-count 0 value uhci-reg
-h# 400 constant /regs - -\ Configuration space registers -my-address my-space encode-phys - 0 encode-int encode+ 0 encode-int encode+ -\ UHCI operational registers -0 0 my-space 0100.0020 + encode-phys encode+ - 0 encode-int encode+ /regs encode-int encode+ -" reg" property - -: map-regs ( -- ) - 4 my-w@ h# 17 or 4 my-w! - 0 0 my-space h# 0100.0020 + /regs map-in to uhci-reg -; +: map-regs ( -- ) /regs my-map-in to uhci-reg ;
: unmap-regs ( -- ) - 4 my-w@ 7 invert and 4 my-w! - uhci-reg /regs map-out 0 to uhci-reg + uhci-reg /regs my-map-out 0 to uhci-reg ;
: uhci-b@ ( idx -- data ) uhci-reg + rb@ ; @@ -52,10 +38,6 @@ : portsc@ ( port -- data ) 2* 10 + uhci-w@ ; : portsc! ( data port -- ) 2* 10 + uhci-w! ;
-: ?disable-smis ( -- ) - 0 my-l@ h# 27c88086 = if h# af00 h# 80 my-w! then -; - : reset-usb ( -- ) uhci-reg dup 0= if map-regs then 4 usbcmd! \ Global reset
openfirmware@openfirmware.info