Angus Ainslie | 3f8667c | 2022-08-25 06:46:02 -0700 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2021 Purism |
| 4 | */ |
| 5 | |
| 6 | #ifndef __LIBREM5_H__ |
| 7 | #define __LIBREM5_H__ |
| 8 | |
| 9 | #define CAMERA_EN IMX_GPIO_NR(1, 0) |
| 10 | #define SD_EN IMX_GPIO_NR(1, 3) |
| 11 | #define AUDIO_EN IMX_GPIO_NR(1, 4) |
| 12 | #define DSI_EN IMX_GPIO_NR(1, 5) |
| 13 | #define SMC_EN IMX_GPIO_NR(1, 6) |
| 14 | #define TYPEC_MUX_EN IMX_GPIO_NR(1, 11) |
| 15 | #define HUB_NRESET IMX_GPIO_NR(1, 12) |
| 16 | #define HUB_EN IMX_GPIO_NR(1, 14) |
| 17 | #define VOL_UP IMX_GPIO_NR(1, 16) |
| 18 | #define VOL_DOWN IMX_GPIO_NR(1, 17) |
| 19 | #define DSI_BIAS_EN IMX_GPIO_NR(1, 20) |
| 20 | #define FLASH_EN IMX_GPIO_NR(1, 23) |
| 21 | #define WWAN_NRESET IMX_GPIO_NR(3, 1) |
| 22 | #define CHG_EN IMX_GPIO_NR(3, 2) |
| 23 | #define CHG_OTG_OUT_EN IMX_GPIO_NR(3, 4) |
| 24 | #define WIFI_EN IMX_GPIO_NR(3, 10) |
| 25 | #define GPS_EN IMX_GPIO_NR(3, 12) |
| 26 | #define BL_EN IMX_GPIO_NR(3, 14) |
| 27 | #define WWAN_EN IMX_GPIO_NR(3, 18) |
| 28 | #define NFC_EN IMX_GPIO_NR(4, 28) |
| 29 | #define LED_G IMX_GPIO_NR(5, 2) |
| 30 | #define LED_R IMX_GPIO_NR(5, 3) |
| 31 | #define LED_B IMX_GPIO_NR(1, 13) |
| 32 | #define MOTO IMX_GPIO_NR(5, 5) |
| 33 | #define SPI1_SCLK IMX_GPIO_NR(5, 6) |
| 34 | #define SPI1_MOSI IMX_GPIO_NR(5, 7) |
| 35 | #define SPI1_MISO IMX_GPIO_NR(5, 8) |
| 36 | #define SPI1_SS0 IMX_GPIO_NR(5, 9) |
| 37 | |
| 38 | #define UART1_TX IMX_GPIO_NR(5, 23) |
| 39 | #define UART1_RX IMX_GPIO_NR(5, 22) |
| 40 | #define UART2_TX IMX_GPIO_NR(5, 25) |
| 41 | #define UART2_RX IMX_GPIO_NR(5, 24) |
| 42 | #define UART3_TX IMX_GPIO_NR(5, 27) |
| 43 | #define UART3_RX IMX_GPIO_NR(5, 26) |
| 44 | #define UART4_TX IMX_GPIO_NR(5, 11) |
| 45 | #define UART4_RX IMX_GPIO_NR(5, 10) |
| 46 | |
| 47 | #define TPS_RESET IMX_GPIO_NR(3, 24) |
| 48 | |
| 49 | #define PURISM_VID 0x316d |
| 50 | #define PURISM_PID 0x4c05 |
| 51 | |
| 52 | #define BOARD_REV_ERROR "unknown" |
| 53 | #define BOARD_REV_BIRCH "1" |
| 54 | #define BOARD_REV_CHESTNUT "2" |
| 55 | #define BOARD_REV_DOGWOOD "3" |
| 56 | #define BOARD_REV_EVERGREEN "4" |
| 57 | /* Could be ASPEN, BIRCH or CHESTNUT. assume CHESTNUT */ |
| 58 | #define BOARD_REV_UNKNOWN BOARD_REV_CHESTNUT |
| 59 | |
| 60 | #ifdef CONFIG_SPL_BUILD |
| 61 | static const iomux_v3_cfg_t configure_pads[] = { |
| 62 | IMX8MQ_PAD_GPIO1_IO00__GPIO1_IO0 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 63 | IMX8MQ_PAD_GPIO1_IO03__GPIO1_IO3 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 64 | IMX8MQ_PAD_GPIO1_IO04__GPIO1_IO4 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 65 | IMX8MQ_PAD_GPIO1_IO05__GPIO1_IO5 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 66 | IMX8MQ_PAD_GPIO1_IO06__GPIO1_IO6 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 67 | IMX8MQ_PAD_GPIO1_IO11__GPIO1_IO11 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 68 | IMX8MQ_PAD_GPIO1_IO12__GPIO1_IO12 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 69 | IMX8MQ_PAD_GPIO1_IO13__GPIO1_IO13 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 70 | IMX8MQ_PAD_GPIO1_IO14__GPIO1_IO14 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 71 | IMX8MQ_PAD_ENET_MDC__GPIO1_IO16 | MUX_PAD_CTRL(PAD_CTL_PUE), |
| 72 | IMX8MQ_PAD_ENET_MDIO__GPIO1_IO17 | MUX_PAD_CTRL(PAD_CTL_PUE), |
| 73 | IMX8MQ_PAD_ENET_TD1__GPIO1_IO20 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 74 | IMX8MQ_PAD_ENET_TXC__GPIO1_IO23 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 75 | IMX8MQ_PAD_NAND_CE0_B__GPIO3_IO1 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 76 | IMX8MQ_PAD_NAND_CE1_B__GPIO3_IO2 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 77 | IMX8MQ_PAD_NAND_CE3_B__GPIO3_IO4 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 78 | IMX8MQ_PAD_NAND_DATA04__GPIO3_IO10 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 79 | IMX8MQ_PAD_NAND_DATA06__GPIO3_IO12 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 80 | IMX8MQ_PAD_NAND_DQS__GPIO3_IO14 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 81 | IMX8MQ_PAD_NAND_WP_B__GPIO3_IO18 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 82 | IMX8MQ_PAD_SAI3_RXFS__GPIO4_IO28 | MUX_PAD_CTRL(PAD_CTL_DSE6), |
| 83 | IMX8MQ_PAD_SAI3_MCLK__GPIO5_IO2 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 84 | IMX8MQ_PAD_SPDIF_TX__GPIO5_IO3 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 85 | IMX8MQ_PAD_SAI5_RXD3__GPIO3_IO24 | MUX_PAD_CTRL(PAD_CTL_DSE6) | MUX_MODE_SION, |
| 86 | }; |
| 87 | |
| 88 | static inline void init_pinmux(void) |
| 89 | { |
| 90 | imx_iomux_v3_setup_multiple_pads(configure_pads, ARRAY_SIZE(configure_pads)); |
| 91 | |
| 92 | gpio_request(LED_R, "LED_R"); |
| 93 | gpio_request(LED_G, "LED_G"); |
| 94 | gpio_request(LED_B, "LED_B"); |
| 95 | gpio_request(VOL_UP, "VOL_UP"); |
| 96 | gpio_request(VOL_DOWN, "VOL_DOWN"); |
| 97 | |
| 98 | gpio_request(NFC_EN, "NFC_EN"); |
| 99 | gpio_request(CHG_EN, "CHG_EN"); |
| 100 | gpio_request(CHG_OTG_OUT_EN, "CHG_OTG_OUT_EN"); |
| 101 | |
| 102 | gpio_request(TYPEC_MUX_EN, "TYPEC_MUX_EN"); |
| 103 | |
| 104 | gpio_request(TPS_RESET, "TPS_RESET"); |
| 105 | |
| 106 | gpio_request(WWAN_EN, "WWAN_EN"); |
| 107 | gpio_request(WWAN_NRESET, "WWAN_NRESET"); |
| 108 | |
| 109 | gpio_request(HUB_EN, "HUB_EN"); |
| 110 | gpio_request(HUB_NRESET, "HUB_NRESET"); |
| 111 | gpio_request(SD_EN, "SD_EN"); |
| 112 | gpio_request(AUDIO_EN, "AUDIO_EN"); |
| 113 | gpio_request(DSI_EN, "DSI_EN"); |
| 114 | gpio_request(SMC_EN, "SMC_EN"); |
| 115 | gpio_request(CAMERA_EN, "CAMERA_EN"); |
| 116 | gpio_request(FLASH_EN, "FLASH_EN"); |
| 117 | gpio_request(DSI_BIAS_EN, "DSI_BIAS_EN"); |
| 118 | gpio_request(GPS_EN, "GPS_EN"); |
| 119 | gpio_request(BL_EN, "BL_EN"); |
| 120 | #ifndef CONSOLE_ON_UART4 |
| 121 | gpio_request(WIFI_EN, "WIFI_EN"); |
| 122 | gpio_direction_output(WIFI_EN, 0); |
| 123 | #endif /* CONSOLE_ON_UART4 */ |
| 124 | gpio_direction_input(VOL_UP); |
| 125 | gpio_direction_input(VOL_DOWN); |
| 126 | |
| 127 | /* ensure charger is in the automated mode */ |
| 128 | gpio_direction_output(NFC_EN, 0); |
| 129 | gpio_direction_output(CHG_EN, 0); |
| 130 | gpio_direction_output(CHG_OTG_OUT_EN, 0); |
| 131 | |
| 132 | gpio_direction_input(TYPEC_MUX_EN); |
| 133 | |
| 134 | gpio_direction_output(TPS_RESET, 0); |
| 135 | |
| 136 | gpio_direction_output(WWAN_EN, 0); |
| 137 | gpio_direction_output(WWAN_NRESET, 1); |
| 138 | |
| 139 | gpio_direction_output(HUB_EN, 1); |
| 140 | gpio_direction_output(HUB_NRESET, 1); |
| 141 | mdelay(10); |
| 142 | gpio_direction_output(SD_EN, 1); |
| 143 | gpio_direction_output(SMC_EN, 0); |
| 144 | gpio_direction_output(CAMERA_EN, 0); |
| 145 | gpio_direction_output(FLASH_EN, 0); |
| 146 | gpio_direction_output(DSI_BIAS_EN, 0); |
| 147 | gpio_direction_output(GPS_EN, 0); |
| 148 | gpio_direction_output(BL_EN, 0); |
| 149 | |
| 150 | /* turn these on for i2c busses */ |
| 151 | gpio_direction_output(AUDIO_EN, 1); |
| 152 | gpio_direction_output(DSI_EN, 1); |
| 153 | } |
| 154 | #endif /* CONFIG_SPL_BUILD */ |
| 155 | |
| 156 | #define USB1_BASE_ADDR 0x38100000 |
| 157 | #define USB2_BASE_ADDR 0x38200000 |
| 158 | #define USB1_PHY_BASE_ADDR 0x381F0000 |
| 159 | #define USB2_PHY_BASE_ADDR 0x382F0000 |
| 160 | |
| 161 | #define USB_PHY_CTRL0 0xF0040 |
| 162 | #define USB_PHY_CTRL0_REF_SSP_EN BIT(2) |
| 163 | #define USB_PHY_CTRL0_SSC_RANGE_MASK GENMASK(23, 21) |
| 164 | #define USB_PHY_CTRL0_SSC_RANGE_4003PPM (0x2 << 21) |
| 165 | |
| 166 | #define USB_PHY_CTRL1 0xF0044 |
| 167 | #define USB_PHY_CTRL1_RESET BIT(0) |
| 168 | #define USB_PHY_CTRL1_COMMONONN BIT(1) |
| 169 | #define USB_PHY_CTRL1_ATERESET BIT(3) |
| 170 | #define USB_PHY_CTRL1_VDATSRCENB0 BIT(19) |
| 171 | #define USB_PHY_CTRL1_VDATDETENB0 BIT(20) |
| 172 | |
| 173 | #define USB_PHY_CTRL2 0xF0048 |
| 174 | #define USB_PHY_CTRL2_TXENABLEN0 BIT(8) |
| 175 | |
| 176 | #define USB_PHY_CTRL6 0x18 |
| 177 | #define USB_PHY_CTRL6_RXTERM_OVERRIDE_SEL BIT(29) |
| 178 | |
| 179 | extern struct dram_timing_info dram_timing_b0; |
| 180 | |
| 181 | #endif |