Linux内核4.14版本——SPI框架(6)——spi驱动编写

目录

1. dts

2. 驱动


这个就和具体设备相关了,这里贴一个demo。

1. dts

uspi0: usi3spi@f0d89000 {
	compatible = "tsm,tsm-spi";
	status = "disabled";
	interrupt-parent = <&gic>;
	interrupts = <0 29 4>;
	reg = <0x0 0xf0d89000 0x0 0x1000>;
	#address-cells = <1>;
	#size-cells = <0>;
	clock-names = "usi_clk";
	reg-shift = <2>;
	pinctrl-name = "default";
	pinctrl-0 = <&PA20_pinctrl>;
	uspics-gpios = <&porta 20 GPIO_ACTIVE_LOW>;
};
&uspi0 {
    status = "okay";
    //max-freq = <48000000>;
    w25q64@00 {
		status = "okay";
		#address-cells = <0x1>;
		#size-cells = <0x0>;
        compatible = "w25q64";
        reg = <0>;
        spi-max-frequency = <10000000>;
    };
};

2. 驱动

#include <linux/err.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/device.h>

#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>

#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
#include <linux/mtd/spi-nor.h>


static int w25q64_probe(struct spi_device *spi)
{
	printk("w25q64_probe 666666\n");
	return 0;
}

static int w25q64_remove(struct spi_device *spi)
{

	return 0;
}


static const struct of_device_id w25q64_of_table[] = {
	{ .compatible = "w25q64" },
	{}
};
MODULE_DEVICE_TABLE(of, w25q64_of_table);

static struct spi_driver w25q64_driver = {
	.driver = {
		.name	= "w25q64",
		.of_match_table = w25q64_of_table,
	},
	.probe	= w25q64_probe,
	.remove	= w25q64_remove,
};

module_spi_driver(w25q64_driver);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mike Lavender");
MODULE_DESCRIPTION("MTD SPI driver for ST M25Pxx flash chips");

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值