//在 lk/platform/msm8226/include/platform/aboot.h 中新增 判斷 判斷pad與pad鏈結得引腳定義
#define p03_plug_in 15 //gpio表中查詢
//在 lk/platform/msm8226/include/platform/iomap.h中修改
#define restart_reason_addr (system_imem_base + 0x565c)
//在lk/platform/msm8226/gpio.c中新增如下:
int gpio_get(uint32_t gpio)
//在lk/inlcude/gpio.h中新增如下
int gpio_get(unsigned nr);
/ //在lk/target/msms8226/init.c 中新增如下
#include static struct qup_i2c_dev *dev = null;
#define software_reset 0x73727374
#define adb_reboot 0x77665501
#define recovery_mode 0x77665502
#define uartlog_mode 0x77665503
#define normal_boot 0x77665504
#define microp_cable_in_trigger 0x02
#define microp_power_key_trigger 0x03
#define scaler_i2c_address (0x37)
#define scaler_image_i2c_address (0xe8)
#define microp_i2c_address (0x15)
#define microp_id_i2c_address (0x00)
#define microp_fw_address (0x01)
#define microp_power_on_reason_address (0x07)
#define microp_vbus_off_address (0x23)
#define microp_power_off_address (0x55)
#define microp_a68_ready_address (0x05
uint8_t read_microp_hwid(uint8_t addr),
};dprintf(critical, "lion->init.c->read_microp_hwid::addr = 0x%d \r\n",addr);
ret = qup_i2c_xfer(dev, msg_buf, 2);
if ( ret < 0 )
return ret;
dprintf(info, "[bl] ret[0] = 0x%x \n", data[0]);
dprintf(info, "[bl] ret[1] = 0x%x \n", data[1]);
dprintf(info, "[bl] ret[2] = 0x%x \n", data[2]);
dprintf(info, "[bl] ret[3] = 0x%x \n", data[3]);
return data[1];
}uint8_t read_microp_fw(uint8_t addr),
};dprintf(critical, "lion->init.c->read_microp_fw::addr = 0x%d \r\n",addr);
qup_i2c_xfer(dev, msg_buf, 2);
dprintf(info, "[bl] ret[0] = 0x%x \n", data[0]);
dprintf(info, "[bl] ret[1] = 0x%x \n", data[1]);
dprintf(info, "[bl] ret[2] = 0x%x \n", data[2]);
dprintf(info, "[bl] ret[3] = 0x%x \n", data[3]);
return data[0];
}uint8_t read_microp_power_on_reason(uint8_t addr),
};dprintf(critical, "lion->init.c->read_microp_power_on_reason::addr = 0x%d \r\n",addr);
qup_i2c_xfer(dev, msg_buf, 2);
dprintf(info, "[bl] ret[0] = 0x%x \n", ret[0]);
dprintf(info, "[bl] ret[1] = 0x%x \n", ret[1]);
dprintf(info, "[bl] ret[2] = 0x%x \n", ret[2]);
dprintf(info, "[bl] ret[3] = 0x%x \n", ret[3]);
return ret[1];
}uint8_t write_microp_a68_ready(uint8_t addr)
};dprintf(critical, "lion->init.c->write_microp_a68_ready::addr = 0x%d \r\n",addr);
ret = qup_i2c_xfer(dev, msg_buf, 1);
return ret;
}uint8_t write_microp_power_off(uint8_t addr)
};dprintf(critical, "lion->init.c->write_microp_power_off::addr = 0x%d \r\n",addr);
ret = qup_i2c_xfer(dev, msg_buf, 1);
return ret;
}void shutdown_device(void)
////target_init+++
//在void target_init(void) 函式中新增如下判斷
void target_init(void)
else
//no
else
}}//end of if ( !(whoami < 0) )
}//end of else (!dev)
} //end of if ( gpio_get(p03_plug_in) )
} ///target_init---
///qup_i2c_init+++
// 修改 lk/platform/msm_shared/i2c_qup.c 中得函式qup_i2c_init
struct qup_i2c_dev *qup_i2c_init(uint8_t gsbi_id, unsigned clk_freq,
unsigned src_clk_freq)
/* this must be done for qup_i2c_interrupt to work. */
dev_addr = dev;
/* configure the gsbi protocol code for i2c */
writel((gsbi_protocol_code_i2c /* set clk_freq and src_clk_freq for i2c. */
dev->clk_freq = clk_freq;
dev->src_clk_freq = src_clk_freq;
dev->num_irqs = 1;
dev->one_bit_t = usec_per_sec / dev->clk_freq;
dev->clk_ctl = 0;
/* register the gsbin qup irq */
register_int_handler(dev->qup_irq, (int_handler) qup_i2c_interrupt, 0);
/* then disable it */
mask_interrupt(dev->qup_irq);
return dev;
}///qup_i2c_init+++
/ clk++
//使能microp 使用得i2c得時鐘 0xf9925000 qup3
//在lk/platform/msm8226/include/platform/iomap.h 中新增 巨集定義 allows sw control of cbc soft macro
clk_ctl_base 為0xfc400000 qup3 0xfc400748
//在/lk/platform/msm8226/msm8226-clock.c中新增如下變數:
,//在msm_clocks_8226結構提中新增
static struct clk_lookup msm_clocks_8226 =
/ clk--
在Aboot中新增i2c使用得方法二
在 lk platform msm8226 include platform aboot.h 中新增 判斷 判斷pad與pad鏈結得引腳定義 define p03 plug in 15 gpio表中查詢 在 lk platform msm8226 include platform iomap.h中修...
i2c我們用得很多,i3c又是什麼?
2.3 i3c 時序圖 2.4 i3c應用場景 2.5 i3c不適用的場景 3 總結 4 參考文章 常見的板級間通訊匯流排有i2c spi uart i2s等,這類匯流排常用於adc dac 感測器 觸控螢幕等等外設中 i2s則用於傳輸音訊資訊,在音訊adc和dac中應用。隨著物聯網的應用越來越廣泛...
在linux驅動中呼叫I2C的方法
一 在相應的平台檔案中新增i2c的註冊資訊 1 建立乙個i2c board info結構體 平台檔案目錄arch arm mach struct tda platform data 這可以隨便定義自己想要的結構 struct tda platform data tda pdata static st...