Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| toh:tp-link:tl-mr3420:deep.mmc.hack [2018/06/30 12:29] – aaded dts patches deoptim | toh:tp-link:tl-mr3420:deep.mmc.hack [2018/07/02 07:56] – minor addings/changes deoptim | ||
|---|---|---|---|
| Line 197: | Line 197: | ||
| </ | </ | ||
| - | <hidden Patch for Openwrt/LEDE (4.14+, ath79 platform, dts files)>< | + | <hidden Patch for Openwrt (4.14+, ath79 platform, dts files)>< |
| diff --git a/ | diff --git a/ | ||
| index 3846d811ac..d845e06951 100644 | index 3846d811ac..d845e06951 100644 | ||
| Line 328: | Line 328: | ||
| </ | </ | ||
| - | <hidden Patch for Openwrt/LEDE (4.14+, ath79 platform, dts files)>< | + | <hidden Patch for Openwrt (4.14+, ath79 platform, dts files)>< |
| diff --git a/ | diff --git a/ | ||
| index 3846d811ac..58399eb4de 100644 | index 3846d811ac..58399eb4de 100644 | ||
| Line 471: | Line 471: | ||
| </ | </ | ||
| - | <hidden Patch for Openwrt/LEDE (4.14+, ath79 platform, dts files)>< | + | <hidden Patch for Openwrt (4.14+, ath79 platform, dts files)>< |
| diff --git a/ | diff --git a/ | ||
| index 3846d811ac..ea915872dc 100644 | index 3846d811ac..ea915872dc 100644 | ||
| Line 521: | Line 521: | ||
| </ | </ | ||
| + | \\ | ||
| == Switching GPIO0 to CS1 on AR71XX SoC: == | == Switching GPIO0 to CS1 on AR71XX SoC: == | ||
| + | <hidden Instruction for old Openwrt (including LEDE project)> | ||
| <code c> | <code c> | ||
| /* Enabling internal CS1, disable GPIO 0 */ | /* Enabling internal CS1, disable GPIO 0 */ | ||
| ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN); | ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN); | ||
| </ | </ | ||
| - | **Note:** This instruction for old Openwrt (before LEDE project). | + | </ |
| + | \\ | ||
| == Switching GPIO0 to CS1 on AR724X SoC: == | == Switching GPIO0 to CS1 on AR724X SoC: == | ||
| + | <hidden Instruction for old Openwrt (including LEDE project)> | ||
| <code c> | <code c> | ||
| /* Enabling internal CS1, disable GPIO 0 */ | /* Enabling internal CS1, disable GPIO 0 */ | ||
| ath79_gpio_function_enable(AR724X_GPIO_FUNC_SPI_CS_EN1); | ath79_gpio_function_enable(AR724X_GPIO_FUNC_SPI_CS_EN1); | ||
| </ | </ | ||
| - | **Note:** Already used in the above example. This instruction for old Openwrt (before LEDE project). | + | </ |
| + | <hidden Instruction for Openwrt (4.14+, ath79 platform, dts files)> | ||
| + | <code c> | ||
| + | ... | ||
| + | ... | ||
| + | /* Add this two lines to spi enum */ | ||
| + | pinctrl-names = " | ||
| + | pinctrl-0 = <& | ||
| + | ... | ||
| + | ... | ||
| + | &pinmux { | ||
| + | enable_cs1_bit: | ||
| + | pinctrl-single, | ||
| + | /* | ||
| + | * Set AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13) to 1, | ||
| + | * i.e. enable hardware CS1 but it turn-off GPIO0; | ||
| + | * Formula: *addr = (*addr & ~sub-mask) | | ||
| + | * (value & sub-mask); | ||
| + | * Where: addr is 0x18000000 + 0x40000 + 0x28 is | ||
| + | * base address of AR724X GPIO functions; | ||
| + | * < | ||
| + | */ | ||
| + | 0x0 0x2000 0x2000 | ||
| + | >; | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | </ | ||
| + | **Note:** Already used in the example | ||
| + | \\ | ||
| == Turn off UART and switching GPIO9(Rx) to CS1 on AR933X SoC: == | == Turn off UART and switching GPIO9(Rx) to CS1 on AR933X SoC: == | ||
| + | <hidden Instruction for old Openwrt (including LEDE project)> | ||
| <code c> | <code c> | ||
| /* Disable UART, enabling GPIO 9 and GPIO 10 */ | /* Disable UART, enabling GPIO 9 and GPIO 10 */ | ||
| Line 543: | Line 574: | ||
| ath79_gpio_function_enable(AR933X_GPIO_FUNC_SPI_CS_EN1); | ath79_gpio_function_enable(AR933X_GPIO_FUNC_SPI_CS_EN1); | ||
| </ | </ | ||
| - | **Note:** This instruction for old Openwrt (before LEDE project). | + | </ |
| + | \\ | ||
| == Configure GPIO11 to CS1 on AR934X SoC: == | == Configure GPIO11 to CS1 on AR934X SoC: == | ||
| + | <hidden Instruction for old Openwrt (including LEDE project)> | ||
| <code c> | <code c> | ||
| /* We chose GPIO11 - for this example. You can use any unused GPIOs(11-22) */ | /* We chose GPIO11 - for this example. You can use any unused GPIOs(11-22) */ | ||
| Line 555: | Line 587: | ||
| ath79_gpio_output_select(DEVICE_GPIO_CS1_MMC, | ath79_gpio_output_select(DEVICE_GPIO_CS1_MMC, | ||
| </ | </ | ||
| - | **Note:** This instruction | + | </ |
| - | + | <hidden Instruction for Openwrt (4.14+, ath79 platform, dts files)> | |
| + | <code c> | ||
| + | ... | ||
| + | ... | ||
| + | /* Add this two lines to spi enum */ | ||
| + | pinctrl-names = " | ||
| + | pinctrl-0 = <& | ||
| + | ... | ||
| + | ... | ||
| + | &pinmux { | ||
| + | gpio11_to_cs1_bit: pinmux_gpio11_to_cs1_bit { | ||
| + | pinctrl-single, | ||
| + | /* | ||
| + | * Set AR934X_GPIO_OUT_SPI_CS1 7 value to GPIO11, | ||
| + | * i.e. enable hardware CS1 but it turn-off GPIO11; | ||
| + | * Formula: *addr = (*addr & ~sub-mask) | | ||
| + | * (value & sub-mask); | ||
| + | * Where: addr is 0x18000000 + 0x40000 + 0x2C is | ||
| + | * base address of AR934X GPIO Output functions; | ||
| + | * < | ||
| + | */ | ||
| + | /* | ||
| + | * 0x2c+0x8 addr_offset | ||
| + | * 0x2c+0xc addr_offset for GPIO12-GPIO15; | ||
| + | * 0x2c+0x10 addr_offset for GPIO16-GPIO19; | ||
| + | * 0x7 value (with Bitwise Left Shift) for mux CS1 | ||
| + | * use 0x8 value for mux CS2; | ||
| + | */ | ||
| + | 0x8 0x7000000 0xff000000 | ||
| + | >; | ||
| + | }; | ||
| + | }; | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| ==== How to implement the Hotplug of SD-card ==== | ==== How to implement the Hotplug of SD-card ==== | ||
| | {{media: | | {{media: | ||
| Line 667: | Line 733: | ||
| </ | </ | ||
| - | // We could use GPIO to IRQ event as card detection (implemented in '' | + | <hidden Patch for Openwrt (4.14+, ath79 platform, dts files)>< |
| + | diff --git a/ | ||
| + | index 3846d811ac..d99bafcb2b 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -22,13 +22,18 @@ | ||
| + | | ||
| + | | ||
| + | | ||
| + | - | ||
| + | qss { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | + mmc { | ||
| + | + label = " | ||
| + | + linux, | ||
| + | + gpios = <& | ||
| + | + debounce-interval = < | ||
| + | + }; | ||
| + | }; | ||
| + | |||
| + | | ||
| + | @@ -48,7 +53,12 @@ | ||
| + | |||
| + | & | ||
| + | | ||
| + | - num-cs = < | ||
| + | + num-cs = < | ||
| + | + /* | ||
| + | + * Where first parameter <0> is default CS0 pin for flash | ||
| + | + * and second parameter is GPIO Number for sdcard. | ||
| + | + */ | ||
| + | + cs-gpios = <0>, <& | ||
| + | |||
| + | | ||
| + | | ||
| + | @@ -80,6 +90,30 @@ | ||
| + | | ||
| + | | ||
| + | }; | ||
| + | + | ||
| + | + sdcard@0 { | ||
| + | + compatible = " | ||
| + | + reg = < | ||
| + | + /* | ||
| + | + * If you need to use GPIO18 as Card Detect and | ||
| + | + * IRQ trigger (as standard implementation) - just | ||
| + | + * uncomment line below (but don't forget delete | ||
| + | + * the equivalent gpio-key). We don't use this | ||
| + | + * property because it doesn' | ||
| + | + * SD Card. | ||
| + | + */ | ||
| + | + //gpios = <& | ||
| + | + /* | ||
| + | + * By default, Card Detect use " | ||
| + | + * Using the " | ||
| + | + * CD line is active high, i.e. it is high, when a | ||
| + | + * card is inserted. | ||
| + | + * (uncomment line below to enable this option) | ||
| + | + */ | ||
| + | + // | ||
| + | + spi-max-frequency = < | ||
| + | + voltage-ranges = <3200 3400>; | ||
| + | + }; | ||
| + | }; | ||
| + | |||
| + | & | ||
| + | |||
| + | </ | ||
| + | // We could use GPIO to IRQ event as card detection (implemented in '' | ||
| Or FIXME // | Or FIXME // | ||
| The solution was found without the use of IRQ trigger: | The solution was found without the use of IRQ trigger: | ||
| **After build and compiling** the firmware, we just added additional button with the name **'' | **After build and compiling** the firmware, we just added additional button with the name **'' | ||
| - | Next, you need to [[docs: | + | Next, you need to [[docs: |
| <code bash> | <code bash> | ||
| uci add system button | uci add system button | ||
| - | uci set system.@button[-1].button=mmc | + | uci set system.@button[-1].button=BTN_0 |
| uci set system.@button[-1].action=pressed | uci set system.@button[-1].action=pressed | ||
| uci set system.@button[-1].handler=' | uci set system.@button[-1].handler=' | ||
| uci add system button | uci add system button | ||
| - | uci set system.@button[-1].button=mmc | + | uci set system.@button[-1].button=BTN_0 |
| uci set system.@button[-1].action=released | uci set system.@button[-1].action=released | ||
| uci set system.@button[-1].handler=' | uci set system.@button[-1].handler=' | ||