Home > other >  Write a driver to boot, didn't see the probe print, warrior, please help me have a look,
Write a driver to boot, didn't see the probe print, warrior, please help me have a look,

Time:09-16

Hello:
Write a driver to boot, didn't see the probe print, warrior, please help me have a look, thank you instruct me,
/*
* ktd2150 driver
*
* Copyright (C) 2013 Texas Instruments
*
* the Author: Milo (Woogyom) Kim & lt; [email protected] & gt;
*
* This program is free software; You can redistribute it and/or modify the
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


Struct ktd2150_platform_data {
Struct notifier_block ktd_fb_notifier;
Struct i2c_client * client;
};

Static int ktd2150_i2c_write (struct i2c_client * client, int addr, int value)
{
Char buf [2]={addr, value};
Struct i2c_msg MSG={
The addr=client - & gt; Addr,
//. Flags=I2C_M_IGNORE_NAK,
. The flags=0,
Len=2,
The buf=buf
};
Int the error;
Error=i2c_transfer (client - & gt; Adapter, & amp; MSG, 1);
Return the error & lt; 0? Error: 0;
}


Int gpio_ktd2150_suspend (struct i2c_client * client)
{
Int ret=0;
//struct i2c_client * client=to_i2c_client (dev);
Printk ("=============Tom test get in ktd2150 suspend=======================\ n ");
Ret=ktd2150_i2c_write (client, 0 x03, 0 x43);
If (ret) {
Printk ("=============write clent register 0 x03 failed!=======================\ n ");
return ret;
}
return 0;
}

EXPORT_SYMBOL (gpio_ktd2150_suspend);

Int gpio_ktd2150_resume (struct i2c_client * client)
{
Int ret=0;
//struct i2c_client * client=to_i2c_client (dev);
Printk ("=============Tom test get in ktd2150 resume=======================\ n ");
Ret=ktd2150_i2c_write (client, 0 x03, 0 x5b);
If (ret) {
Printk ("=============write clent register 0 x03 failed!=======================\ n ");
return ret;
}
return 0;
}

EXPORT_SYMBOL (gpio_ktd2150_resume);

/*
Static int fb_notifier_callback (struct notifier_block * nb,
Unsigned long action, void * data)
{
Volatile int blank;
Struct fb_event * evdata=https://bbs.csdn.net/topics/data;
Const struct ktd2150_platform_data * pdata=https://bbs.csdn.net/topics/
Container_of (nb, struct ktd2150_platform_data ktd_fb_notifier);
Printk ("====================Tom test FB notifier callback========================\ n ");

If (evdata & amp; & Evdata - & gt; Data) {
If (action==FB_EVENT_BLANK) {
Blank=* (int *) evdata - & gt; The data;
If (blank==FB_BLANK_UNBLANK) {
Gpio_ktd2150_resume (pdata - & gt; The client);
Return NOTIFY_OK;
}
{} else if (action==FB_EARLY_EVENT_BLANK)
Blank=* (int *) evdata - & gt; The data;
If (blank==FB_BLANK_POWERDOWN) {
Gpio_ktd2150_suspend (pdata - & gt; The client);
Return NOTIFY_OK;
}
}
}

Return NOTIFY_DONE;
}

Static int ktd2150_init_pm_fb_notifier (struct ktd2150_platform_data * pdata)
{
Printk ("====Tom test Init FB notifier=================\ n ");

Pdata - & gt; Ktd_fb_notifier. Notifier_call=fb_notifier_callback;

Return fb_register_client (& amp; Pdata - & gt; Ktd_fb_notifier);
}
*/
Static int ktd2150_init_device (struct i2c_client * client)
{
Int ret=0;
//int I=0;
//gpio_direction_output (pdata - & gt; Enp_gpio, 1);
//gpio_direction_output (pdata - & gt; Enn_gpio, 1);
//msleep (100);
/* ret=ktd2150_i2c_write (client, 0 x02, 0 x0f);
If (ret) {
Printk ("=============write clent register 0 x02 failed!=======================\ n ");
return ret;
}
Ret=ktd2150_i2c_write (client, 0 x02, 0 x08);
If (ret) {
Printk ("=============write clent register 0 x02 failed!=======================\ n ");
return ret;
} */
Ret=ktd2150_i2c_write (client, 0 x00 to 0 xb8);
If (ret) {
Printk ("=============client_addr: % d write clent register 0 x00 failed!=======================\ n ", the client - & gt; Addr);
return ret;
}
Ret=ktd2150_i2c_write (client, 0 x01, 0 xb8);
If (ret) {
Printk ("=============write clent register 0 x01 failed!=======================\ n ");
return ret;
}

//for(i=0; i<1000; I++) {
Ret=ktd2150_i2c_write (client, 0 x03, 0 x5b);
//msleep (1);
//}
If (ret) {
Printk ("=============write clent register 0 x03 failed!=======================\ n ");
return ret;
}
return ret;

}

Static int ktd2150_parse_dt (struct device * dev)
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull