Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1583

RZA1 RSK Adding Device Tree Node for MMC0

$
0
0

I need to use the latest backported drivers from TI to support a radio with the RZA1. Previous versions of these drivers supported platform data set from a board file, or device tree data. Now, the latest drivers only support the device tree. The radio connects to the RZA1 RSK in the SD card slot, and so the kernel refers to this as device "mmc0":

mmc0: queuing unknown CIS tuple 0x91 (3 bytes)
mmc0: new high speed SDIO card at address 0001

The board file that ships with the RZA1 uses a hybrid model with most things being defined in board-rskrza1.c and some things defined in r7272100.dtsi and r7s72100-rskrza1.dts. The sd card slot is defined in the board file with these lines:

/* SDHI1 */
static struct sh_mobile_sdhi_info sdhi1_pdata = {
    .dma_slave_tx = RZA1DMA_SLAVE_SDHI1_TX,
    .dma_slave_rx = RZA1DMA_SLAVE_SDHI1_RX,
    .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
    .tmio_ocr_mask = MMC_VDD_32_33,
    .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
};

static const struct resource sdhi1_resources[] __initconst = {
    DEFINE_RES_MEM_NAMED(0xe804e800, 0x100, "SDHI1"),
    DEFINE_RES_IRQ_NAMED(gic_iid(305), SH_MOBILE_SDHI_IRQ_CARD_DETECT),
    DEFINE_RES_IRQ_NAMED(gic_iid(306), SH_MOBILE_SDHI_IRQ_SDCARD),
    DEFINE_RES_IRQ_NAMED(gic_iid(307), SH_MOBILE_SDHI_IRQ_SDIO),
};

static const struct platform_device_info sdhi1_info __initconst = {
    .name = "sh_mobile_sdhi",
    .id = 1,
    .res = sdhi1_resources,
    .num_res = ARRAY_SIZE(sdhi1_resources),
    .data = &sdhi1_pdata,
    .size_data = sizeof(sdhi1_pdata),
    .dma_mask = DMA_BIT_MASK(32),
};

TI's example device tree entry that works with their latest driver looks like this:

&mmc2 {
    status = "okay";
    vmmc-supply = <&wlan_en_reg>;
    bus-width = <4>;
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&mmc2_pins &wlan_pins_default>;
    pinctrl-1 = <&mmc2_pins_sleep &wlan_pins_sleep>;
    ti,non-removable;
    ti,needs-special-hs-handling;
    cap-power-off-card;
    keep-power-in-suspend;

    #address-cells = <1>;
    #size-cells = <0>;
    wlcore: wlcore@0 {
        compatible = "ti,wl1835";
        reg = <2>;
        interrupt-parent = <&gpio0>;
        interrupts = <7 IRQ_TYPE_EDGE_RISING>;
    };
};

I tried to add the wlcore sub node to the RZA1 device tree like this in r7s72100.dtsi:

mmc0: mmc@e804e800 {

    status = "okay";
    wlcore: wlcore@0 {
        compatible = "ti,wl1835";
        reg = <2>;
        interrupt-parent = <&gic>;
        interrupts = <38 IRQ_TYPE_EDGE_RISING>;
    };

};

The driver code parses the device tree like this:

static int wlcore_probe_of(struct device *dev, int *irq, struct wlcore_platdev_data *pdev_data)
{

    // CUSTOM CUSTOMIZATION FOR DEBUGGING
    printk("WL18XX: wlcore_probe_of() - Probing OF now!\n");

    struct device_node *np = dev->of_node;

    // CUSTOM CUSTOMIZATION FOR DEBUGGING
    if ( !np ) {
        printk("WL18XX: wlcore_probe_of() - Do not have an np!\n");
    }
    else {
        printk("WL18XX: wlcore_probe_of() - Device node: %s [%s]\n",np->name,np->type);
    }

    // CUSTOM CUSTOMIZATION FOR DEBUGGING
    if (!np || !of_match_node(wlcore_sdio_of_match_table, np)) {
        printk("WL18XX: wlcore_probe_of() - Can't find node in device tree!\n");
        return -ENODATA;
    }
    else {
        // CUSTOM CUSTOMIZATION FOR DEBUGGING
        printk("WL18XX: wlcore_probe_of() - Found node in device tree!\n");
    }

    *irq = irq_of_parse_and_map(np, 0);
    if (!*irq) {
        dev_err(dev, "No irq in platform data\n");
        kfree(pdev_data);
        return -EINVAL;
    }

    /* optional clock frequency params */
    of_property_read_u32(np, "ref-clock-frequency",
    &pdev_data->ref_clock_freq);
    of_property_read_u32(np, "tcxo-clock-frequency",
    &pdev_data->tcxo_clock_freq);

    return 0;

}

static int wl1271_probe(struct sdio_func *func,

const struct sdio_device_id *id)
{

    // CUSTOM CUSTOMIZATION FOR DEBUGGING
    printk("WL18XX: wl1271_probe() - Probing WILINK now!\n");

    struct wlcore_platdev_data pdev_data;
    struct wl12xx_sdio_glue *glue;
    struct resource res[1];
    mmc_pm_flag_t mmcflags;
    int ret = -ENOMEM;
    int irq;
    const char *chip_family;

    /* We are only able to handle the wlan function */
    if (func->num != 0x02)
        return -ENODEV;

    memset(&pdev_data, 0x00, sizeof(pdev_data));
    pdev_data.if_ops = &sdio_ops;

    glue = kzalloc(sizeof(*glue), GFP_KERNEL);
    if (!glue) {
        dev_err(&func->dev, "can't allocate glue\n");
        goto out;
    }

    glue->dev = &func->dev;

    /* Grab access to FN0 for ELP reg. */
    func->card->quirks |= MMC_QUIRK_LENIENT_FN0;

    /* Use block mode for transferring over one block size of data */
    func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;

    ret = wlcore_probe_of(&func->dev, &irq, &pdev_data);
    if (ret)
        goto out_free_glue; <---------- IT ALWAYS FAILS HERE

But when I load the modules, it can never find the appropriate node in the device tree:

Loading modules backported from Linux version R8.7_SP1-0-g13c25bc
Backport generated by backports.git R8.7_SP1-0-gd4777ef
WL18XX: wl1271_probe() - Probing WILINK now!
WL18XX: wl1271_probe() - Probing WILINK now!
WL18XX: wlcore_probe_of() - Probing OF now!
WL18XX: wlcore_probe_of() - Do not have an np!
WL18XX: wlcore_probe_of() - Can't find node in device tree!
wl1271_sdio: probe of mmc0:0001:2 failed with error -61

How can I get this to work - to find the SD Card node from the device tree? Thanks.


Viewing all articles
Browse latest Browse all 1583

Trending Articles