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/02/16 15:10] – tmomas | toh:tp-link:tl-mr3420:deep.mmc.hack [2018/06/30 12:29] – aaded dts patches deoptim | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| <WRAP center important 70%> | <WRAP center important 70%> | ||
| - | This mod does not work on the new **trunk** and **Chaos Calmer 15.05** (since the revision [[https:// | + | This mod does not work on the older **//LEDE//** and **//Chaos Calmer 15.05//** (since the revision [[https:// |
| + | **But it works completely on the newest kernel 4.14+(ath79) and does not need to delete anything.** | ||
| \\ | \\ | ||
| - | You need to discard this three changes to work property with this mod. | + | If you use older version of branch then you need to discard/ |
| - | \\ | + | |
| - | Now just remove three patches from git repository: | + | |
| < | < | ||
| git rm target/ | git rm target/ | ||
| Line 13: | Line 12: | ||
| git rm target/ | git rm target/ | ||
| </ | </ | ||
| - | You can also do this in same way for other branches... | + | **Note:** Instead of path **patches-3.18**, |
| + | You can also do remove those patches | ||
| ---- | ---- | ||
| Or you can use old **Barrier Breaker 14.07** branch or **Chaos Calmer 15.05** branch (up to revision r47042).\\ | Or you can use old **Barrier Breaker 14.07** branch or **Chaos Calmer 15.05** branch (up to revision r47042).\\ | ||
| Line 34: | Line 34: | ||
| And two ways for installing the required modules for detect and use the SD memory card is connected to the SPI bus of device.\\ | And two ways for installing the required modules for detect and use the SD memory card is connected to the SPI bus of device.\\ | ||
| - | At software level, this modification is almost no different from [[:doc:howto: | + | At software level, this modification is almost no different from [[docs:guide-user:hardware: |
| - | How to build your own firmware is covered here: [[:doc:howto:build]].\\ | + | How to build your own firmware is covered here: [[:docs:guide-developer:build-system: |
| If you already have experience with compile own firmware, and you want to easy apply these changes as patch(es), you can just use this Linux console command: | If you already have experience with compile own firmware, and you want to easy apply these changes as patch(es), you can just use this Linux console command: | ||
| | Svn patch\\ file format: | < | | Svn patch\\ file format: | < | ||
| Line 46: | Line 46: | ||
| **Note:** Keep in mind, very often the unused GPIOs a pulled-down to the ground or pulled-up to the power bus via resistor - this may affect on detection of SD memory cards. | **Note:** Keep in mind, very often the unused GPIOs a pulled-down to the ground or pulled-up to the power bus via resistor - this may affect on detection of SD memory cards. | ||
| | {{media: | | {{media: | ||
| + | \\ | ||
| + | \\ | ||
| ==== First way, using common CS0 ==== | ==== First way, using common CS0 ==== | ||
| {{: | {{: | ||
| == Main changes in the source code of kernel: == | == Main changes in the source code of kernel: == | ||
| - | <code diff> | + | <hidden Old patch for Openwrt (before LEDE project)> |
| diff --git a/ | diff --git a/ | ||
| index 9323b31..2c51142 100644 | index 9323b31..2c51142 100644 | ||
| Line 136: | Line 137: | ||
| tl_mr3x20_gpio_keys); | tl_mr3x20_gpio_keys); | ||
| - | </ | + | </ |
| + | <hidden Patch for Openwrt/ | ||
| + | diff --git a/ | ||
| + | index e53d97d..269e469 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -7,8 +7,10 @@ | ||
| + | */ | ||
| + | |||
| + | # | ||
| + | +#include < | ||
| + | # | ||
| + | # | ||
| + | +#include < | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | @@ -16,6 +18,11 @@ | ||
| + | # | ||
| + | # | ||
| + | |||
| + | +static struct mmc_spi_platform_data ath79_mmc_data = { | ||
| + | + .detect_delay = 100, /* msecs */ | ||
| + | + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | ||
| + | +}; | ||
| + | + | ||
| + | | ||
| + | { | ||
| + | | ||
| + | @@ -27,18 +34,25 @@ static struct spi_board_info ath79_spi_info[] = { | ||
| + | | ||
| + | | ||
| + | | ||
| + | - .modalias = " | ||
| + | + .modalias = " | ||
| + | + .platform_data = & | ||
| + | } | ||
| + | }; | ||
| + | |||
| + | +static int device_spi_cs_gpios[2] = { | ||
| + | + -ENOENT, | ||
| + | + 2, /* GPIO Number */ | ||
| + | +}; | ||
| + | + | ||
| + | | ||
| + | |||
| + | void __init ath79_register_m25p80(struct flash_platform_data *pdata) | ||
| + | { | ||
| + | | ||
| + | - ath79_spi_data.num_chipselect = 1; | ||
| + | + ath79_spi_data.num_chipselect = 2; | ||
| + | + ath79_spi_data.cs_gpios = device_spi_cs_gpios; | ||
| + | | ||
| + | - ath79_register_spi(& | ||
| + | + ath79_register_spi(& | ||
| + | } | ||
| + | |||
| + | | ||
| + | </ | ||
| + | <hidden Patch for Openwrt/ | ||
| + | diff --git a/ | ||
| + | index 3846d811ac..d845e06951 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -48,7 +48,19 @@ | ||
| + | |||
| + | & | ||
| + | | ||
| + | - num-cs = <1>; | ||
| + | + num-cs = <2>; | ||
| + | + /* | ||
| + | + * First value is default pin for flash, second value | ||
| + | + * (via comma) the GPIO number for sdcard. But we used | ||
| + | + * gpio 2 and it equivalent of internal CS0 line. And | ||
| + | + * we use it because we use common bus SPI0.0 for two | ||
| + | + * devices (default Low polarity chip-select, | ||
| + | + * High polarity chip-select). | ||
| + | + * In its core, this is a dummy, because internal CS0 line | ||
| + | + * is locked by HW and SPI driver, and we can not use it at all. | ||
| + | + * We use this to simply switch SPI bus to another device. | ||
| + | + */ | ||
| + | + cs-gpios = <0>, <& | ||
| + | |||
| + | | ||
| + | | ||
| + | @@ -80,6 +92,13 @@ | ||
| + | }; | ||
| + | }; | ||
| + | }; | ||
| + | + | ||
| + | + sdcard@0 { | ||
| + | + compatible = " | ||
| + | + reg = <1>; | ||
| + | + spi-max-frequency = < | ||
| + | + voltage-ranges = <3200 3400>; | ||
| + | + }; | ||
| + | }; | ||
| + | |||
| + | & | ||
| + | |||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| ==== Second way, using GPIO as CS1 (Recommended) ==== | ==== Second way, using GPIO as CS1 (Recommended) ==== | ||
| Recommended to use any unused GPIO-pin as CS1 for MMC/SD memory card. | Recommended to use any unused GPIO-pin as CS1 for MMC/SD memory card. | ||
| == Main changes in the source code of kernel: == | == Main changes in the source code of kernel: == | ||
| - | <code diff> | + | <hidden Old patch for Openwrt (before LEDE project)> |
| diff --git a/ | diff --git a/ | ||
| index e5831d4..80760d5 100644 | index e5831d4..80760d5 100644 | ||
| Line 224: | Line 327: | ||
| tl_mr3x20_gpio_keys); | tl_mr3x20_gpio_keys); | ||
| - | </ | + | </code></ |
| + | <hidden Patch for Openwrt/ | ||
| + | diff --git a/ | ||
| + | index 3846d811ac..58399eb4de 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -48,7 +48,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 +85,13 @@ | ||
| + | | ||
| + | | ||
| + | }; | ||
| + | + | ||
| + | + sdcard@0 { | ||
| + | + compatible = " | ||
| + | + reg = < | ||
| + | + spi-max-frequency = < | ||
| + | + voltage-ranges = <3200 3400>; | ||
| + | + }; | ||
| + | }; | ||
| + | |||
| + | & | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| ==== Third way, using Internal CS1 ==== | ==== Third way, using Internal CS1 ==== | ||
| Line 242: | Line 380: | ||
| == Main changes in the source code of kernel: == | == Main changes in the source code of kernel: == | ||
| - | <code diff> | + | <hidden Old patch for Openwrt (before LEDE project)> |
| diff --git a/ | diff --git a/ | ||
| index e5831d4..80760d5 100644 | index e5831d4..80760d5 100644 | ||
| Line 332: | Line 470: | ||
| tl_mr3x20_gpio_keys); | tl_mr3x20_gpio_keys); | ||
| - | </ | + | </code></ |
| + | <hidden Patch for Openwrt/ | ||
| + | diff --git a/ | ||
| + | index 3846d811ac..ea915872dc 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -48,7 +48,10 @@ | ||
| + | |||
| + | & | ||
| + | | ||
| + | - num-cs = < | ||
| + | + pinctrl-names = " | ||
| + | + pinctrl-0 = <& | ||
| + | + num-cs = < | ||
| + | + cs-gpios = <0>, < | ||
| + | |||
| + | | ||
| + | | ||
| + | @@ -80,6 +83,30 @@ | ||
| + | | ||
| + | | ||
| + | }; | ||
| + | + | ||
| + | + sdcard@0 { | ||
| + | + compatible = " | ||
| + | + reg = < | ||
| + | + spi-max-frequency = < | ||
| + | + voltage-ranges = <3200 3400>; | ||
| + | + }; | ||
| + | +}; | ||
| + | + | ||
| + | +& | ||
| + | + 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 | ||
| + | + >; | ||
| + | + }; | ||
| + | }; | ||
| + | |||
| + | & | ||
| + | |||
| + | </ | ||
| == Switching GPIO0 to CS1 on AR71XX SoC: == | == Switching GPIO0 to CS1 on AR71XX SoC: == | ||
| Line 339: | Line 527: | ||
| 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: == | ||
| Line 345: | Line 534: | ||
| ath79_gpio_function_enable(AR724X_GPIO_FUNC_SPI_CS_EN1); | ath79_gpio_function_enable(AR724X_GPIO_FUNC_SPI_CS_EN1); | ||
| </ | </ | ||
| - | //(Already used in the above example.)// | + | **Note: |
| == Turn off UART and switching GPIO9(Rx) to CS1 on AR933X SoC: == | == Turn off UART and switching GPIO9(Rx) to CS1 on AR933X SoC: == | ||
| Line 354: | Line 543: | ||
| 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: == | ||
| Line 365: | Line 555: | ||
| ath79_gpio_output_select(DEVICE_GPIO_CS1_MMC, | ath79_gpio_output_select(DEVICE_GPIO_CS1_MMC, | ||
| </ | </ | ||
| + | **Note:** This instruction for old Openwrt (before LEDE project). | ||
| Line 373: | Line 564: | ||
| Total we use two unused GPIOs: **GPIO7-> | Total we use two unused GPIOs: **GPIO7-> | ||
| Create a new additional button on this example: | Create a new additional button on this example: | ||
| - | <code diff> | + | <hidden Old patch for Openwrt (before LEDE project)> |
| diff --git a/ | diff --git a/ | ||
| index e5831d4..80760d5 100644 | index e5831d4..80760d5 100644 | ||
| Line 475: | Line 666: | ||
| tl_mr3x20_gpio_keys); | tl_mr3x20_gpio_keys); | ||
| - | </ | + | </code></ |
| // We could use GPIO to IRQ event as card detection (implemented in '' | // We could use GPIO to IRQ event as card detection (implemented in '' | ||
| Or FIXME // | Or FIXME // | ||
| Line 481: | Line 672: | ||
| 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 [[:doc:howto: | + | Next, you need to [[docs:guide-user:hardware: |
| <code bash> | <code bash> | ||
| uci add system button | uci add system button | ||
| Line 517: | Line 708: | ||
| ==== Modules installation ==== | ==== Modules installation ==== | ||
| === First way, build it in kernel (Recommended) === | === First way, build it in kernel (Recommended) === | ||
| - | | {{: | + | | {{: |
| Line 543: | Line 734: | ||
| === Second way, using external modules === | === Second way, using external modules === | ||
| - | | {{: | + | | {{: |
| ** Update: ** The problem remained in **r37142** firmware revision.\\ | ** Update: ** The problem remained in **r37142** firmware revision.\\ | ||
| - | For [[doc:howto:extroot]], use First way. | + | For [[docs:guide-user:additional-software: |