当前位置:网站首页>Pilote d'adaptateur I2C
Pilote d'adaptateur I2C
2022-07-21 16:10:00 【Juno.】
I2C adapterCadre d'entraînement
struct xxx_i2c {
void __iomem *base; /* PourmapRegistre périphérique */
struct device *dev; /* Pas de route spéciale */
struct i2c_adapter adap; /* adapter Structure des données */
struct clk *clk;
u32 quick; /* Capacité de support de l'appareil */
};
static u32 xxx_i2c_functionality(struct i2c_adapter *adap)
{
struct s5pv210_i2c *i2c = container_of(adap, struct s5pv210_i2c, adap);
return i2c->quick;
}
static int xxx_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write,
u8 cmd, int size, union i2c_smbus_data *data)
{
return 0;
}
static const struct i2c_algorithm xxx_i2c_algo = {
.smbus_xfer = xxx_smbus_xfer, /* I2C Le Contrôleur envoie et reçoit des données */
.functionality = xxx_i2c_functionality, /* Obtenir les fonctions supportées par l'appareil */
};
static int xxx_i2c_register(struct xxx_i2c *i2c)
{
struct i2c_adapter *adap = &i2c->adap;
adap->algo = &xxx_i2c_algo;
adap->algo.dev.of_node = i2c->dev->of_node;
adap->alog.dev.parent = i2c->dev;
adap->owner = THIS_MODULE;
adap->quick = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C;
return i2c_add_adapter(adap); /* Ajouter un adaptateur au noyau */
}
static int xxx_i2c_probe(struct platform_device *pdev)
{
struct xxx_i2c *i2c;
int ret;
i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); /* Distribuer les données privées de l'appareil */
if (!i2c)
return -ENOMEM;
i2c->dev = &pdev->dev;
i2c->base = devm_platform_ioremap_resource(pdev, 0); /* map Mémoire du registre */
if (IS_ERR(i2c->base)) {
return PTR_ERR(i2c->base);
}
ret = xxx_i2c_register(i2c);
if (ret)
return ret;
platform_set_drvdata(pdev, i2c);
return 0;
}
static int xxx_i2c_remove(struct platform_device *pdev)
{
struct xxx_i2c *i2c = platform_get_drvdata(pdev);
i2c_del_adapter(&i2c->adap);
return 0;
}
const struct of_device_id xxx_ids[] = {
{
.compatible = "xxx,i2c-adapter"},
};
struct platform_driver xxx_i2c_adap_drv = {
.probe = xxx_i2c_probe,
.remove = xxx_i2c_remove,
.driver = {
.name = "xxx-i2c-adaper",
.of_match_table = xxx_ids,
},
};
module_platform_driver(xxx_i2c_adap_drv);
InI2C adapterEn mouvementalgoDansfunctionality La fonction de rappel renvoie les fonctions supportées par l'appareil , Ces fonctions sont définies dans uapi/linux/i2c.hMoyenne.
smbus_xfer Cette fonction est utilisée pour I2CL'appareil envoie des données.
边栏推荐
- 如果没有选中任何线型, CAcUiLineTypeComboBox 崩溃的原因
- 致测试/开发程序员:爱生活,不加班,苦逼的程序员......
- Calculate the centrifugal angle according to the center angle of the circle
- deadlock
- 2.4 circular statements
- TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation
- DTOS帝拓思的3D引擎将取代游戏引擎巨兽,实现国产化替代
- 【Star项目】小帽飞机大战(一)
- ROS从入门到精通(十) TF坐标变换原理,为什么需要TF变换?
- L'ipaylinks, un service d'intégration des paiements transfrontaliers, a remporté le prix 3A Asia de l'actif!
猜你喜欢
小程序毕设作品之微信疫苗预约小程序毕业设计(4)开题报告
[Yugong series] go teaching course in July 2022 014 arithmetic operators of operators
投影&局部光照
Wechat vaccine appointment applet graduation project of applet completion work (6) opening defense ppt
Wechat vaccine appointment applet graduation design of applet completion work (2) applet function
Lighting plus
Esp8266 nodemcu - connect WiFi using WiFi manager Library
Wechat vaccine appointment applet graduation design of applet completion work (8) graduation design thesis template
原码、补码以及定点数运算
数据库约束&&MySQL进阶查询
随机推荐
每日一题-LeetCode1260-二维网格迁移-数组-映射
Wechat vaccine reservation applet graduation design of applet completion work (3) background function
In the e-commerce industry with fierce competition, why can the chain 2+1 mode survive for so long?
word报告参考文献格式
利用 vtk 的控件画圆和矩形
[JS] mouse follow
Dynamic characteristics and interaction in virtual environment
小程序毕设作品之微信疫苗预约小程序毕业设计(8)毕业设计论文模板
Signal integrity (SI) power integrity (PI) learning notes (xxx) power distribution network (II)
Lighting plus
【Flutter -- 实战】快速入门 Flutter
Source code, complement and fixed-point number operation
传统零售企业如何促进消费循环、分享购模式赋能实体企业发展?
Wechat vaccine appointment applet graduation project of applet completion work (6) opening defense ppt
What preliminary work does the enterprise need to do to establish its own applet and app?
DTOS帝拓思的3D引擎將取代遊戲引擎巨獸,實現國產化替代
How can traditional retail enterprises promote consumption cycle and share purchase mode to enable the development of physical enterprises?
[super easy to understand competition questions] 2021 Sichuan University Student Program Design Competition
c || 数组与指针
2022 Shandong vision prevention and control conference, China eye care products exhibition, Jinan myopia correction equipment exhibition