F1C100S添加USB驱动

描述

F1C100S添加USB驱动

1.添加设备树节点:

  在.dti文件中添加如下节点:

otg_sram: sram-section@0 {
    compatible = "allwinner,suniv-f1c100s-sram-d",
             "allwinner,sun4i-a10-sram-d";
    reg = <0x0000 0x1000>;
    status = "disabled";
};

Linux

usb_otg: usb@1c13000 {
    compatible = "allwinner,suniv-musb";
    reg = <0x01c13000 0x0400>;
    clocks = <&ccu CLK_BUS_OTG>;
    resets = <&ccu RST_BUS_OTG>;
    interrupts = <26>;
    interrupt-names = "mc";
    phys = <&usbphy 0>;
    phy-names = "usb";
    extcon = <&usbphy 0>;
    allwinner,sram = <&otg_sram 1>;
    status = "disabled";
};

usbphy: phy@1c13400 {
    compatible = "allwinner,suniv-usb-phy";
    reg = <0x01c13400 0x10>;
    reg-names = "phy_ctrl";
    clocks = <&ccu CLK_USB_PHY0>;
    clock-names = "usb0_phy";
    resets = <&ccu RST_USB_PHY0>;
    reset-names = "usb0_reset";
    #phy-cells = <1>;
    status = "disabled";
};

Linux

然后在dts中开启设备节点:

&otg_sram {
        status = "okay";
};

&usb_otg {
        dr_mode = "otg";
        status = "okay";
};

&usbphy {
        usb0_id_det-gpio = <&pio 4 2 GPIO_ACTIVE_HIGH>; /* PE2 */
        status = "okay";
};

Linux

2.由于linux并没有对F1C100s写驱动,因此我们需要添加其驱动程序,步骤如下:

drivers/phy/allwinner/phy-sun4i-usb.c文件修改如下

大约在100行处添加:
suniv_phy,

Linux

大约在862处添加:

static const struct sun4i_usb_phy_cfg suniv_cfg = {
    .num_phys = 1,
    .type = suniv_phy,
    .disc_thresh = 3,
    .phyctl_offset = REG_PHYCTL_A10,
    .dedicated_clocks = true,
};

Linux

大约在985处添加:

{ .compatible = "allwinner,suniv-usb-phy", .data = &suniv_cfg },

Linux

drivers/usb/musb/sunxi.c文件修改如下

大约在717行添加如下:
||of_device_is_compatible(np, "allwinner,suniv-musb")

 大约在724处添加如下:

||of_device_is_compatible(np, "allwinner,suniv-musb")

Linux

大约在817处添加如下:

{ .compatible = "allwinner,suniv-musb", },

Linux

修改好后保存所有修改文件

3.选择usb驱动添加到内核:

Linux

Linux

Linux

然后保存退出

4.编译测试:

Linux

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分