update for device bulk access and in-system tuning
authora0220410 <peter-li@ti.com>
Mon, 4 Jul 2016 17:49:00 +0000 (01:49 +0800)
committera0220410 <peter-li@ti.com>
Mon, 4 Jul 2016 17:49:00 +0000 (01:49 +0800)
Makefile
tas2555-core.c
tas2555-i2c.c
tas2555.h
tiload.c
tiload.h

index 3d2f08a892cabcf6d8e687d9d40055cba732de59..0d546b8d40b64448890dc078beedc22c2c517ff5 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
-snd-soc-tas2555-objs := tas2555-core.o tas2555-codec.o tas2555-misc.o tas2555-i2c.o
+snd-soc-tas2555-objs := tas2555-core.o tas2555-codec.o tas2555-misc.o tiload.o tas2555-i2c.o
 obj-$(CONFIG_SND_SOC_TAS2555_STEREO) += snd-soc-tas2555.o
\ No newline at end of file
index af8a5791e4758b07044121456e65fbea6981bbf0..b1045eac4f48918d0e5541697cbaa173a5286c9d 100755 (executable)
@@ -395,8 +395,8 @@ static int fw_parse_header(struct tas2555_priv *pTAS2555,
        pFirmware->mnPPCVersion = fw_convert_number(pData);
        pData += 4;
 
-       pFirmware->mnDSPFWVersion = fw_convert_number(pData);
-       pData += 4;
+//     pFirmware->mnDSPFWVersion = fw_convert_number(pData);
+//     pData += 4;
        
        pFirmware->mnDrvFWVersion = fw_convert_number(pData);
        pData += 4;
index d863176a5a0e5133ead18e87507f554897823645..9629ead951a0825228f6cf701d5cc6ca8b00583c 100755 (executable)
 #include "tiload.h"
 #endif
 
+/*
+* tas2555_i2c_write_device : write single byte to device
+* platform dependent, need platform specific support
+*/
 static int tas2555_i2c_write_device(
        struct tas2555_priv *pTAS2555,
        unsigned char addr, 
@@ -91,7 +95,50 @@ static int tas2555_i2c_write_device(
        return 0;
 }
 
-int tas2555_i2c_read_device(   
+/*
+* tas2555_i2c_bulkwrite_device : write multiple bytes to device
+* platform dependent, need platform specific support
+*/
+static int tas2555_i2c_bulkwrite_device(
+       struct tas2555_priv *pTAS2555,
+       unsigned char addr, 
+       unsigned char reg, 
+       unsigned char *pBuf,
+       unsigned int len)
+{
+       int ret;
+       u8 data[ 1 + len];
+       struct i2c_msg *msg = &pTAS2555->xfer_msg[0];
+
+       msg->addr = addr;
+       msg->len = 2;
+       msg->flags = 0;
+       data[0] = reg;
+       memcpy(&data[1], pBuf, len);    
+       msg->buf = data;
+       ret = i2c_transfer(
+               pTAS2555->client->adapter, 
+               pTAS2555->xfer_msg, 1);
+       /* Try again if the write fails */
+       if (ret != 1) {
+               ret = i2c_transfer(
+                       pTAS2555->client->adapter, 
+                       pTAS2555->xfer_msg, 1);
+               if (ret != 1) {
+                       dev_err(pTAS2555->dev, 
+                               "failed to multiple write the device, %d\n", ret);
+                       return ret;
+               }
+       }
+       
+       return 0;
+}
+
+/*
+* tas2555_i2c_read_device : read single byte from device
+* platform dependent, need platform specific support
+*/
+static int tas2555_i2c_read_device(    
        struct tas2555_priv *pTAS2555,
        unsigned char addr, 
        unsigned char reg, 
@@ -126,6 +173,51 @@ int tas2555_i2c_read_device(
        return 0;
 }
 
+/*
+* tas2555_i2c_bulkread_device : read multiple bytes from device
+* platform dependent, need platform specific support
+*/
+static int tas2555_i2c_bulkread_device(        
+       struct tas2555_priv *pTAS2555,
+       unsigned char addr, 
+       unsigned char reg, 
+       unsigned char *p_value,
+       unsigned int len)
+{
+       struct i2c_msg *msg;
+       int ret = 0;
+
+       msg = &pTAS2555->xfer_msg[0];
+       msg->addr = addr;
+       msg->len = 1;
+       msg->flags = 0;
+       msg->buf = &reg;
+       msg = &pTAS2555->xfer_msg[1];
+       msg->addr = addr;
+       msg->len = len;
+       msg->flags = I2C_M_RD;
+       msg->buf = p_value;
+       ret = i2c_transfer(pTAS2555->client->adapter,
+                       pTAS2555->xfer_msg, 2);
+
+       /* Try again if read fails first time */
+       if (ret != 2) {
+               ret = i2c_transfer(pTAS2555->client->adapter,
+                                  pTAS2555->xfer_msg, 2);
+               if (ret != 2) {
+                       dev_err(pTAS2555->dev, 
+                               "failed to bulk read the device, %d\n", ret);
+                       return ret;
+               }
+       }
+       
+       return 0;
+}
+
+/* 
+* tas2555_change_book_page : switch to certain book and page
+* platform independent, don't change unless necessary
+*/
 static int tas2555_change_book_page(
        struct tas2555_priv *pTAS2555, 
        enum channel chn,
@@ -178,6 +270,10 @@ static int tas2555_change_book_page(
        return nResult;
 }
 
+/* 
+* tas2555_dev_read :
+* platform independent, don't change unless necessary
+*/
 static int tas2555_dev_read(
        struct tas2555_priv *pTAS2555,
        enum channel chn,
@@ -217,6 +313,10 @@ static int tas2555_dev_read(
        return nResult;
 }
 
+/* 
+* tas2555_dev_write :
+* platform independent, don't change unless necessary
+*/
 static int tas2555_dev_write(
        struct tas2555_priv *pTAS2555,
        enum channel chn,
@@ -266,6 +366,10 @@ static int tas2555_dev_write(
        return nResult;
 }
 
+/* 
+* tas2555_dev_bulk_read :
+* platform independent, don't change unless necessary
+*/
 static int tas2555_dev_bulk_read(
        struct tas2555_priv *pTAS2555,
        enum channel chn,
@@ -273,7 +377,7 @@ static int tas2555_dev_bulk_read(
        u8 * pData, 
        unsigned int nLength)
 {
-       int nResult = 0, i;
+       int nResult = 0;
        unsigned char reg = 0;
        unsigned char Addr = 0;
        
@@ -302,9 +406,8 @@ static int tas2555_dev_bulk_read(
                }
                
                if(nResult >= 0){
-                       for(i = 0; i < nLength; i++){
-                               nResult = tas2555_i2c_read_device(pTAS2555, Addr, reg+i, &pData[i]);
-                       }                       
+                       nResult = tas2555_i2c_bulkread_device(
+                               pTAS2555, Addr, reg, pData, nLength);
                }
        }
                                                                        
@@ -313,6 +416,10 @@ static int tas2555_dev_bulk_read(
        return nResult;
 }
 
+/* 
+* tas2555_dev_bulk_write :
+* platform independent, don't change unless necessary
+*/
 static int tas2555_dev_bulk_write(
        struct tas2555_priv *pTAS2555,
        enum channel chn,
@@ -321,7 +428,6 @@ static int tas2555_dev_bulk_write(
        unsigned int nLength)
 {
        int nResult = 0;
-       int i;
        unsigned char reg = 0;
        
        mutex_lock(&pTAS2555->dev_lock);
@@ -342,22 +448,22 @@ static int tas2555_dev_bulk_write(
        if(nResult >=0){
                reg = TAS2555_PAGE_REG(nRegister);      
                if(chn & channel_left){
-                       for(i = 0; i < nLength; i++){
-                               tas2555_i2c_write_device(
-                                       pTAS2555, 
-                                       pTAS2555->mnLAddr, 
-                                       reg+i, 
-                                       pData[i]);
+                       nResult = tas2555_i2c_bulkwrite_device(
+                               pTAS2555,
+                               pTAS2555->mnLAddr,
+                               reg, pData, nLength);
+                       if(nResult < 0){
+                               dev_err(pTAS2555->dev, "bulk write error %d\n", nResult);
                        }
                }
                
                if(chn & channel_right){
-                       for(i = 0; i < nLength; i++){
-                               tas2555_i2c_write_device(
-                                       pTAS2555, 
-                                       pTAS2555->mnRAddr, 
-                                       reg+i, 
-                                       pData[i]);
+                       nResult = tas2555_i2c_bulkwrite_device(
+                               pTAS2555,
+                               pTAS2555->mnRAddr,
+                               reg, pData, nLength);
+                       if(nResult < 0){
+                               dev_err(pTAS2555->dev, "bulk write error %d\n", nResult);
                        }
                }
        }
@@ -366,6 +472,10 @@ static int tas2555_dev_bulk_write(
        return nResult;
 }
 
+/* 
+* tas2555_dev_update_bits :
+* platform independent, don't change unless necessary
+*/
 static int tas2555_dev_update_bits(
        struct tas2555_priv *pTAS2555,
        enum channel chn,
@@ -416,6 +526,11 @@ static int tas2555_dev_update_bits(
        return nResult;
 }
 
+/* 
+* tas2555_i2c_probe :
+* platform dependent
+* should implement hardware reset functionality
+*/
 static int tas2555_i2c_probe(struct i2c_client *pClient,
        const struct i2c_device_id *pID)
 {
@@ -442,11 +557,17 @@ static int tas2555_i2c_probe(struct i2c_client *pClient,
                dev_err(&pClient->dev, " dt error\n");
                return -EINVAL;
        }
+
+#ifdef HARD_RESET      
+       //TODO implement hardware reset here to both TAS2555 devices
+       //platform dependent
+       udelay(1000);
+#else  
        pTAS2555->mnLCurrentBook = -1;
        pTAS2555->mnLCurrentPage = -1;
        pTAS2555->mnRCurrentBook = -1;
        pTAS2555->mnRCurrentPage = -1;
-       
+#endif 
        /* Reset the chip */
        nResult = tas2555_dev_write(pTAS2555, channel_both, TAS2555_SW_RESET_REG, 1);
        if(nResult < 0){
@@ -489,8 +610,12 @@ static int tas2555_i2c_probe(struct i2c_client *pClient,
 #endif
 
 #ifdef CONFIG_TAS2555_MISC_STEREO      
-       mutex_init(&pTAS2555->file_lock);
-       tas2555_register_misc(pTAS2555);
+               mutex_init(&pTAS2555->file_lock);
+               tas2555_register_misc(pTAS2555);
+#endif
+
+#ifdef ENABLE_TILOAD
+               tiload_driver_init(pTAS2555);
 #endif
 
        }
index ec4bc9d888c2724e27c7fff6e15dec2fc3af6d45..d12453f42de8f8241b75c882360a041faea6e92d 100755 (executable)
--- a/tas2555.h
+++ b/tas2555.h
 /* B100P0R31 - TAS2555_CLK_MISC_REG */
 #define TAS2555_DSP_CLK_FROM_PLL               (0x1 << 5)
 
-#define TAS2555_FW_NAME     "tas2555_uCDSP.bin"
+#define TAS2555_FW_NAME     "tas2555s_uCDSP.bin"
 
 typedef struct {
        unsigned int mnType;
index e8a077a21be8cd18d221e7b81786e96660f86faf..04553f4bf40c9bb975ef776911e4eb2eacaf7078 100755 (executable)
--- a/tiload.c
+++ b/tiload.c
@@ -22,7 +22,7 @@
 **
 ** =============================================================================
 */
-
+#define DEBUG
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <asm/uaccess.h>
 
 #include "tiload.h"
-
-/* enable debug prints in the driver */
-#define DEBUG
-
-#ifdef DEBUG
-#define dprintk(x...)   printk(x)
-#else
-#define dprintk(x...)
-#endif
-
-//#ifdef TI_LOAD
-
 /* Function prototypes */
-#ifdef REG_DUMP
-static void dump_page(struct i2c_client *i2c, u8 page);
-#endif
 
 /* externs */
-//extern int aic3262_change_page(struct snd_soc_codec *codec, u8 new_page);
-//extern int aic3262_change_book(struct snd_soc_codec *codec, u8 new_book);
-//extern int aic3262_write(struct snd_soc_codec *codec, unsigned int reg,
-//             unsigned int value);
-
 static struct cdev *tiload_cdev;
 static int tiload_major = 0;   /* Dynamic allocation of Mjr No. */
 static int tiload_opened = 0;  /* Dynamic allocation of Mjr No. */
 static struct tas2555_priv *g_TAS2555;
 struct class *tiload_class;
 static unsigned int magic_num = 0x00;
-//static int (*codec_write) (struct snd_soc_codec *, unsigned int, unsigned int) = 0;
-//static unsigned int (*codec_read) (struct snd_soc_codec *, unsigned int) = 0; 
 
 static char gPage = 0;
 static char gBook = 0;
 /******************************** Debug section *****************************/
 
-#ifdef REG_DUMP
-/*
- *----------------------------------------------------------------------------
- * Function : dump_page
- * Purpose  : Read and display one codec register page, for debugging purpose
- *----------------------------------------------------------------------------
- */
-static void dump_page(struct i2c_client *i2c, u8 page)
-{
-/*
-    int i;
-    u8 data;
-    u8 test_page_array[8];
-
-    dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
-//    aic3262_change_page(codec, page);
-
-    data = 0x0;
-
-    i2c_master_send(i2c, data, 1);
-    i2c_master_recv(i2c, test_page_array, 8);
-
-    printk("\n------- aic3262 PAGE %d DUMP --------\n", page);
-    for (i = 0; i < 8; i++) {
-        printk(" [ %d ] = 0x%x\n", i, test_page_array[i]);
-    }
-*/
-}
-#endif
-
 /*
  *----------------------------------------------------------------------------
  * Function : tiload_open
@@ -115,12 +63,16 @@ static void dump_page(struct i2c_client *i2c, u8 page)
  */
 static int tiload_open(struct inode *in, struct file *filp)
 {
-       dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
+       struct tas2555_priv *pTAS2555 = g_TAS2555;
+       
+       dev_info(pTAS2555->dev, "%s\n", __FUNCTION__);
        if (tiload_opened) {
-               printk("%s device is already opened\n", "tiload");
-               printk("%s: only one instance of driver is allowed\n", "tiload");
+               dev_info(pTAS2555->dev, "%s device is already opened\n", "tiload");
+               dev_info(pTAS2555->dev, "%s: only one instance of driver is allowed\n", "tiload");
                return -1;
        }
+       
+       filp->private_data = (void*)pTAS2555;
        tiload_opened++;
        return 0;
 }
@@ -134,7 +86,10 @@ static int tiload_open(struct inode *in, struct file *filp)
  */
 static int tiload_release(struct inode *in, struct file *filp)
 {
-       dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
+       struct tas2555_priv *pTAS2555 = (struct tas2555_priv *)filp->private_data;
+       
+       dev_info(pTAS2555->dev, "%s\n", __FUNCTION__);
+       
        tiload_opened--;
        return 0;
 }
@@ -150,6 +105,7 @@ static int tiload_release(struct inode *in, struct file *filp)
 static ssize_t tiload_read(struct file *file, char __user * buf,
        size_t count, loff_t * offset)
 {
+       struct tas2555_priv *pTAS2555 = (struct tas2555_priv *)file->private_data;      
        static char rd_data[MAX_LENGTH + 1];
        unsigned int nCompositeRegister = 0, Value;
        //unsigned int n;
@@ -159,18 +115,18 @@ static ssize_t tiload_read(struct file *file, char __user * buf,
 #ifdef DEBUG
        int i;
 #endif
-//    struct i2c_client *i2c = g_codec->control_data;
 
-       dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
+       dev_dbg(pTAS2555->dev, "%s\n", __FUNCTION__);
+       
        if (count > MAX_LENGTH) {
-               printk("Max %d bytes can be read\n", MAX_LENGTH);
+               dev_err(pTAS2555->dev, "Max %d bytes can be read\n", MAX_LENGTH);
                return -1;
        }
 
        /* copy register address from user space  */
        size = copy_from_user(&reg_addr, buf, 1);
        if (size != 0) {
-               printk("read: copy_from_user failure\n");
+               dev_err(pTAS2555->dev, "read: copy_from_user failure\n");
                return -1;
        }
 
@@ -178,32 +134,36 @@ static ssize_t tiload_read(struct file *file, char __user * buf,
 
        nCompositeRegister = BPR_REG(gBook, gPage, reg_addr);
        if (count == 1) {
-               ret =
-                       g_TAS2555->read(g_TAS2555, 0x80000000 | nCompositeRegister, &Value);
+               ret = pTAS2555->read(pTAS2555, 
+                                       pTAS2555->mnCurrentChannel, 
+                                       0x80000000 | nCompositeRegister, &Value);
                if (ret >= 0)
                        rd_data[0] = (char) Value;
        } else if (count > 1) {
-               ret =
-                       g_TAS2555->bulk_read(g_TAS2555, 0x80000000 | nCompositeRegister,
-                       rd_data, size);
+               ret = pTAS2555->bulk_read(pTAS2555, 
+                                       pTAS2555->mnCurrentChannel, 
+                                       0x80000000 | nCompositeRegister, rd_data, size);
        }
        if (ret < 0)
-               printk("%s, %d, ret=%d, count=%zu error happen!\n", __FUNCTION__,
-                       __LINE__, ret, count);
-//    size = i2c_master_recv(i2c, rd_data, count);
+               dev_err(pTAS2555->dev, 
+                               "%s, %d, ret=%d, count=%zu error happen!\n", 
+                               __FUNCTION__, __LINE__, ret, count);
+
 #ifdef DEBUG
-       printk(KERN_ERR "read size = %d, reg_addr= %x , count = %d\n",
+       dev_dbg(pTAS2555->dev, 
+               "read size = %d, reg_addr= 0x%x , count = %d\n",
                (int) size, reg_addr, (int) count);
        for (i = 0; i < (int) size; i++) {
-               printk(KERN_ERR "rd_data[%d]=%x\n", i, rd_data[i]);
+               dev_dbg(pTAS2555->dev, "rd_data[%d]=0x%x\n", i, rd_data[i]);
        }
 #endif
        if (size != count) {
-               printk("read %d registers from the codec\n", (int) size);
+               dev_err(pTAS2555->dev, 
+                       "read %d registers from the codec\n", (int) size);
        }
 
        if (copy_to_user(buf, rd_data, size) != 0) {
-               dprintk("copy_to_user failed\n");
+               dev_err(pTAS2555->dev, "copy_to_user failed\n");
                return -1;
        }
 
@@ -220,37 +180,36 @@ static ssize_t tiload_read(struct file *file, char __user * buf,
 static ssize_t tiload_write(struct file *file, const char __user * buf,
        size_t count, loff_t * offset)
 {
+       struct tas2555_priv *pTAS2555 = (struct tas2555_priv *)file->private_data;              
        static char wr_data[MAX_LENGTH + 1];
        char *pData = wr_data;
        size_t size;
        unsigned int nCompositeRegister = 0;
-//    u8 pg_no;
-//    unsigned int n;   
        unsigned int nRegister;
        int ret = 0;
 #ifdef DEBUG
        int i;
 #endif
-//    struct i2c_client *i2c = g_codec->control_data;
 
-       dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
+       dev_info(pTAS2555->dev, "%s\n", __FUNCTION__);
 
        if (count > MAX_LENGTH) {
-               printk("Max %d bytes can be read\n", MAX_LENGTH);
+               dev_err(pTAS2555->dev,"Max %d bytes can be read\n", MAX_LENGTH);
                return -1;
        }
 
        /* copy buffer from user space  */
        size = copy_from_user(wr_data, buf, count);
        if (size != 0) {
-               printk("copy_from_user failure %d\n", (int) size);
+               dev_err(pTAS2555->dev,
+                       "copy_from_user failure %d\n", (int) size);
                return -1;
        }
 #ifdef DEBUG
-       printk(KERN_ERR "write size = %zu\n", count);
+       dev_dbg(pTAS2555->dev, "write size = %zu\n", count);
        for (i = 0; i < (int) count; i++) {
 
-               printk(KERN_INFO "\nwr_data[%d]=%x\n", i, wr_data[i]);
+               dev_dbg(pTAS2555->dev,"\nwr_data[%d]=%x\n", i, wr_data[i]);
        }
 #endif
        nRegister = wr_data[0];
@@ -269,16 +228,19 @@ static ssize_t tiload_write(struct file *file, const char __user * buf,
        nCompositeRegister = BPR_REG(gBook, gPage, nRegister);
        if (count == 2) {
                ret =
-                       g_TAS2555->write(g_TAS2555, 0x80000000 | nCompositeRegister,
-                       pData[1]);
+                       pTAS2555->write(pTAS2555, 
+                               pTAS2555->mnCurrentChannel, 
+                               0x80000000 | nCompositeRegister, pData[1]);
        } else if (count > 2) {
                ret =
-                       g_TAS2555->bulk_write(g_TAS2555, 0x80000000 | nCompositeRegister,
-                       &pData[1], count - 1);
+                       pTAS2555->bulk_write(pTAS2555, 
+                               pTAS2555->mnCurrentChannel, 
+                               0x80000000 | nCompositeRegister, &pData[1], count - 1);
        }
        if (ret < 0)
-               printk("%s, %d, ret=%d, count=%zu, ERROR Happen\n", __FUNCTION__,
-                       __LINE__, ret, count);
+               dev_err(pTAS2555->dev,
+                       "%s, %d, ret=%d, count=%zu, ERROR Happen\n", 
+                       __FUNCTION__, __LINE__, ret, count);
 #else
        for (n = 1; n < count; n++) {
                nCompositeRegister = BPR_REG(gBook, gPage, nRegister + n - 1);
@@ -290,50 +252,68 @@ static ssize_t tiload_write(struct file *file, const char __user * buf,
        return size;
 }
 
-static void tiload_route_IO(unsigned int bLock)
+static void tiload_route_IO(struct tas2555_priv *pTAS2555, 
+       unsigned int bLock)
 {
        if (bLock) {
-               g_TAS2555->write(g_TAS2555, 0xAFFEAFFE, 0xBABEBABE);
+               pTAS2555->write(pTAS2555, 
+                       pTAS2555->mnCurrentChannel, 
+                       0xAFFEAFFE, 0xBABEBABE);
        } else {
-               g_TAS2555->write(g_TAS2555, 0xBABEBABE, 0xAFFEAFFE);
+               pTAS2555->write(pTAS2555, 
+                       pTAS2555->mnCurrentChannel, 
+                       0xBABEBABE, 0xAFFEAFFE);
        }
 }
 
 static long tiload_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
        long num = 0;
+       struct tas2555_priv *pTAS2555 = (struct tas2555_priv *)filp->private_data;              
        void __user *argp = (void __user *) arg;
        int val;
-
        BPR bpr;
 
-       printk(KERN_ERR "tiload_ioctl\n\r");
+       dev_info(pTAS2555->dev, "%s\n", __FUNCTION__);
 //    if (_IOC_TYPE(cmd) != TILOAD_IOC_MAGIC)
 //        return -ENOTTY;
 
-       dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
        switch (cmd) {
        case TILOAD_IOMAGICNUM_GET:
                num = copy_to_user(argp, &magic_num, sizeof(int));
                break;
        case TILOAD_IOMAGICNUM_SET:
                num = copy_from_user(&magic_num, argp, sizeof(int));
-               tiload_route_IO(magic_num);
+               tiload_route_IO(pTAS2555, magic_num);
                break;
+       case TILOAD_IOCHLNUM_SET:
+               {
+                       int channel = 0;
+                       num = copy_from_user(&channel, argp, sizeof(int));
+                       if((channel>=1)&&(channel<=3))
+                               pTAS2555->mnCurrentChannel = channel;
+                       else{
+                               dev_err(pTAS2555->dev, 
+                                       "TILOAD_IOCHLNUM_SET err chl %d\n", 
+                                       channel);
+                       }
+               }
+               break;  
        case TILOAD_BPR_READ:
                break;
        case TILOAD_BPR_WRITE:
                num = copy_from_user(&bpr, argp, sizeof(BPR));
-               printk("TILOAD_BPR_WRITE: 0x%02X, 0x%02X, 0x%02X\n\r", bpr.nBook,
+               dev_dbg(pTAS2555->dev, 
+                       "TILOAD_BPR_WRITE: 0x%02X, 0x%02X, 0x%02X\n\r", bpr.nBook,
                        bpr.nPage, bpr.nRegister);
                break;
        case TILOAD_IOCTL_SET_CONFIG:
                num = copy_from_user(&val, argp, sizeof(val));
-               g_TAS2555->set_config(g_TAS2555, val);
+               pTAS2555->set_config(pTAS2555, val);
                break;
        case TILOAD_IOCTL_SET_CALIBRATION:
                num = copy_from_user(&val, argp, sizeof(val));
-               g_TAS2555->set_calibration(g_TAS2555, val);
+               pTAS2555->set_calibration(pTAS2555, val);
                break;                          
        default:
                break;
@@ -361,38 +341,44 @@ static struct file_operations tiload_fops = {
 int tiload_driver_init(struct tas2555_priv *pTAS2555)
 {
        int result;
+       dev_t dev;
 
-       dev_t dev = MKDEV(tiload_major, 0);
-       dprintk("TiLoad DRIVER : %s\n", __FUNCTION__);
+       dev_info(pTAS2555->dev, "%s\n", __FUNCTION__);
+       dev = MKDEV(tiload_major, 0);
        g_TAS2555 = pTAS2555;
 
-       dprintk("allocating dynamic major number\n");
-
        result = alloc_chrdev_region(&dev, 0, 1, DEVICE_NAME);
        if (result < 0) {
-               dprintk("cannot allocate major number %d\n", tiload_major);
+               dev_err(pTAS2555->dev,
+                       "cannot allocate major number %d\n", tiload_major);
                return result;
        }
        tiload_class = class_create(THIS_MODULE, DEVICE_NAME);
        tiload_major = MAJOR(dev);
-       dprintk("allocated Major Number: %d\n", tiload_major);
+       dev_info(pTAS2555->dev,
+               "allocated Major Number: %d\n", tiload_major);
 
        tiload_cdev = cdev_alloc();
        cdev_init(tiload_cdev, &tiload_fops);
        tiload_cdev->owner = THIS_MODULE;
        tiload_cdev->ops = &tiload_fops;
 
-       if (device_create(tiload_class, NULL, dev, NULL, "tiload_node") == NULL)
-               dprintk(KERN_ERR "Device creation failed\n");
+       if (device_create(tiload_class, NULL, dev, NULL, "tiload_node") == NULL){
+               dev_err(pTAS2555->dev,
+                       "Device creation failed\n");
+       }
 
        if (cdev_add(tiload_cdev, dev, 1) < 0) {
-               dprintk("tiload_driver: cdev_add failed \n");
+               dev_err(pTAS2555->dev,
+                               "tiload_driver: cdev_add failed \n");
                unregister_chrdev_region(dev, 1);
                tiload_cdev = NULL;
                return 1;
        }
-       printk("Registered TiLoad driver, Major number: %d \n", tiload_major);
-       //class_device_create(tiload_class, NULL, dev, NULL, DEVICE_NAME, 0);
+       
+       dev_info(pTAS2555->dev,
+               "Registered TiLoad driver, Major number: %d \n", tiload_major);
+       
        return 0;
 }
 
index 6d874c3819b7e36f32fe670fb810ce919fade47f..b55c949b6b860870f88ec276b6c53c8158f76b82 100755 (executable)
--- a/tiload.h
+++ b/tiload.h
@@ -47,8 +47,9 @@ typedef struct {
 #define TILOAD_IOMAGICNUM_SET                          _IOW(TILOAD_IOC_MAGIC, 2, int)
 #define TILOAD_BPR_READ                                _IOR(TILOAD_IOC_MAGIC, 3, BPR)
 #define TILOAD_BPR_WRITE                               _IOW(TILOAD_IOC_MAGIC, 4, BPR)
-#define TILOAD_IOCTL_SET_CONFIG                _IOW(TILOAD_IOC_MAGIC, 5, int)
-#define TILOAD_IOCTL_SET_CALIBRATION   _IOW(TILOAD_IOC_MAGIC, 6, int)
+#define TILOAD_IOCHLNUM_SET                    _IOW(TILOAD_IOC_MAGIC, 5, int)
+#define TILOAD_IOCTL_SET_CONFIG                _IOW(TILOAD_IOC_MAGIC, 6, int)
+#define TILOAD_IOCTL_SET_CALIBRATION   _IOW(TILOAD_IOC_MAGIC, 7, int)
 
 int tiload_driver_init(struct tas2555_priv *pTAS2555);