svec: kill blanks/tabs and useless comments

parent edae999b
...@@ -119,7 +119,6 @@ static int svec_gpio_config(struct fmc_device *fmc, struct fmc_gpio *gpio, ...@@ -119,7 +119,6 @@ static int svec_gpio_config(struct fmc_device *fmc, struct fmc_gpio *gpio,
static int svec_read_ee(struct fmc_device *fmc, int pos, void *data, int len) static int svec_read_ee(struct fmc_device *fmc, int pos, void *data, int len)
{ {
if (!(fmc->flags & FMC_DEVICE_HAS_GOLDEN)) if (!(fmc->flags & FMC_DEVICE_HAS_GOLDEN))
return -ENOTSUPP; return -ENOTSUPP;
return svec_eeprom_read(fmc, pos, data, len); return svec_eeprom_read(fmc, pos, data, len);
......
...@@ -18,6 +18,7 @@ module_param_named(i2c_dump, svec_i2c_dump, int, 0444); ...@@ -18,6 +18,7 @@ module_param_named(i2c_dump, svec_i2c_dump, int, 0444);
static uint32_t core_offset[] = { 0x10000, 0x11000 }; static uint32_t core_offset[] = { 0x10000, 0x11000 };
/* shifted versions of fmc_readl/writel to the i2c core */
static void i2c_writel(struct fmc_device *fmc, uint32_t val, int offset) static void i2c_writel(struct fmc_device *fmc, uint32_t val, int offset)
{ {
fmc_writel(fmc, val, core_offset[fmc->slot_id] + offset); fmc_writel(fmc, val, core_offset[fmc->slot_id] + offset);
...@@ -28,9 +29,6 @@ static uint32_t i2c_readl(struct fmc_device *fmc, int offset) ...@@ -28,9 +29,6 @@ static uint32_t i2c_readl(struct fmc_device *fmc, int offset)
return fmc_readl(fmc, core_offset[fmc->slot_id] + offset); return fmc_readl(fmc, core_offset[fmc->slot_id] + offset);
} }
#define fmc_readl i2c_readl
#define fmc_writel i2c_writel
/* Stupid dumping tool */ /* Stupid dumping tool */
static void dumpstruct(char *name, void *ptr, int size) static void dumpstruct(char *name, void *ptr, int size)
{ {
...@@ -51,9 +49,9 @@ static void oc_i2c_init(struct fmc_device *fmc) ...@@ -51,9 +49,9 @@ static void oc_i2c_init(struct fmc_device *fmc)
{ {
const int prescaler = 200; const int prescaler = 200;
fmc_writel(fmc, (prescaler >> 8) & 0xff, I2C_REG_PRER_HI); i2c_writel(fmc, (prescaler >> 8) & 0xff, I2C_REG_PRER_HI);
fmc_writel(fmc, prescaler & 0xff, I2C_REG_PRER_LO); i2c_writel(fmc, prescaler & 0xff, I2C_REG_PRER_LO);
fmc_writel(fmc, I2C_CTR_EN, I2C_REG_CTR); i2c_writel(fmc, I2C_CTR_EN, I2C_REG_CTR);
} }
static uint32_t oc_i2c_wait_busy(struct fmc_device *fmc) static uint32_t oc_i2c_wait_busy(struct fmc_device *fmc)
...@@ -61,7 +59,7 @@ static uint32_t oc_i2c_wait_busy(struct fmc_device *fmc) ...@@ -61,7 +59,7 @@ static uint32_t oc_i2c_wait_busy(struct fmc_device *fmc)
uint32_t sr; uint32_t sr;
do { do {
sr = fmc_readl(fmc, I2C_REG_SR); sr = i2c_readl(fmc, I2C_REG_SR);
} while(sr & I2C_SR_TIP); } while(sr & I2C_SR_TIP);
return sr; return sr;
...@@ -71,19 +69,19 @@ static int oc_i2c_scan_bus(struct fmc_device *fmc) ...@@ -71,19 +69,19 @@ static int oc_i2c_scan_bus(struct fmc_device *fmc)
{ {
int i, ack; int i, ack;
uint32_t sr; uint32_t sr;
for (i = 0; i < 256; i += 2) { for (i = 0; i < 256; i += 2) {
fmc_writel(fmc, i | 1, I2C_REG_TXR); i2c_writel(fmc, i | 1, I2C_REG_TXR);
fmc_writel(fmc, I2C_CR_STA | I2C_CR_WR, I2C_REG_CR); i2c_writel(fmc, I2C_CR_STA | I2C_CR_WR, I2C_REG_CR);
sr = oc_i2c_wait_busy(fmc); sr = oc_i2c_wait_busy(fmc);
ack = !(sr & I2C_SR_RXACK); ack = !(sr & I2C_SR_RXACK);
if (ack) { if (ack) {
pr_info("Device found at address 0x%x\n", i >> 1); pr_info("Device found at address 0x%x\n", i >> 1);
fmc_writel(fmc, 0,I2C_REG_TXR); i2c_writel(fmc, 0,I2C_REG_TXR);
fmc_writel(fmc, I2C_CR_STO | I2C_CR_WR, I2C_REG_CR); i2c_writel(fmc, I2C_CR_STO | I2C_CR_WR, I2C_REG_CR);
oc_i2c_wait_busy(fmc); oc_i2c_wait_busy(fmc);
return 1; return 1;
} }
...@@ -94,52 +92,52 @@ static int oc_i2c_scan_bus(struct fmc_device *fmc) ...@@ -94,52 +92,52 @@ static int oc_i2c_scan_bus(struct fmc_device *fmc)
static int oc_i2c_write(struct fmc_device *fmc, int i2c_addr, const uint8_t *buf, size_t size) static int oc_i2c_write(struct fmc_device *fmc, int i2c_addr, const uint8_t *buf, size_t size)
{ {
uint32_t sr; uint32_t sr;
fmc_writel(fmc, i2c_addr << 1, I2C_REG_TXR);
fmc_writel(fmc, I2C_CR_STA | I2C_CR_WR, I2C_REG_CR); pr_debug("%s: entering [ addr %x ]\n", __func__, i2c_addr);
i2c_writel(fmc, i2c_addr << 1, I2C_REG_TXR);
i2c_writel(fmc, I2C_CR_STA | I2C_CR_WR, I2C_REG_CR);
sr = oc_i2c_wait_busy(fmc); sr = oc_i2c_wait_busy(fmc);
if (sr & I2C_SR_RXACK) if (sr & I2C_SR_RXACK)
return -1; return -1;
while (size--) { while (size--) {
fmc_writel(fmc, *buf++, I2C_REG_TXR); i2c_writel(fmc, *buf++, I2C_REG_TXR);
fmc_writel(fmc, I2C_CR_WR | (size == 0 ? I2C_CR_STO : 0), I2C_REG_CR); i2c_writel(fmc, I2C_CR_WR | (size == 0 ? I2C_CR_STO : 0), I2C_REG_CR);
sr = oc_i2c_wait_busy(fmc); sr = oc_i2c_wait_busy(fmc);
if (sr & I2C_SR_RXACK) if (sr & I2C_SR_RXACK)
return -1; return -1;
} }
// fmc_writel(fmc, I2C_CR_STO, I2C_REG_CR);
// sr = oc_i2c_wait_busy(fmc);
return 0; return 0;
} }
static int oc_i2c_read(struct fmc_device *fmc, int i2c_addr, uint8_t *buf, size_t size) static int oc_i2c_read(struct fmc_device *fmc, int i2c_addr, uint8_t *buf, size_t size)
{ {
uint32_t sr; uint32_t sr;
pr_debug("%s: entering size %zd\n", __func__, size);
i2c_writel(fmc, (i2c_addr << 1) | 1, I2C_REG_TXR);
i2c_writel(fmc, I2C_CR_STA | I2C_CR_WR, I2C_REG_CR);
fmc_writel(fmc, (i2c_addr << 1) | 1, I2C_REG_TXR);
fmc_writel(fmc, I2C_CR_STA | I2C_CR_WR, I2C_REG_CR);
sr = oc_i2c_wait_busy(fmc); sr = oc_i2c_wait_busy(fmc);
if (sr & I2C_SR_RXACK) if (sr & I2C_SR_RXACK)
return -1; return -1;
while (size--) { while (size--) {
uint8_t r; uint8_t r;
fmc_writel(fmc, I2C_CR_RD, I2C_REG_CR); i2c_writel(fmc, I2C_CR_RD, I2C_REG_CR);
sr = oc_i2c_wait_busy(fmc); sr = oc_i2c_wait_busy(fmc);
if (sr & I2C_SR_RXACK) if (sr & I2C_SR_RXACK)
return -1; return -1;
r = fmc_readl(fmc, I2C_REG_RXR) & 0xff; r = i2c_readl(fmc, I2C_REG_RXR) & 0xff;
*buf++ = r; *buf++ = r;
} }
fmc_writel(fmc, I2C_CR_STO | I2C_CR_RD, I2C_REG_CR); i2c_writel(fmc, I2C_CR_STO | I2C_CR_RD, I2C_REG_CR);
sr = oc_i2c_wait_busy(fmc); sr = oc_i2c_wait_busy(fmc);
return 0; return 0;
...@@ -149,7 +147,7 @@ int svec_eeprom_read(struct fmc_device *fmc, uint32_t offset, ...@@ -149,7 +147,7 @@ int svec_eeprom_read(struct fmc_device *fmc, uint32_t offset,
void *buf, size_t size) void *buf, size_t size)
{ {
uint8_t txbuf[2]; uint8_t txbuf[2];
txbuf[0] = (offset >> 8) & 0xff; txbuf[0] = (offset >> 8) & 0xff;
txbuf[1] = offset & 0xff; txbuf[1] = offset & 0xff;
...@@ -163,14 +161,13 @@ int svec_eeprom_write(struct fmc_device *fmc, uint32_t offset, ...@@ -163,14 +161,13 @@ int svec_eeprom_write(struct fmc_device *fmc, uint32_t offset,
const void *buf, size_t size) const void *buf, size_t size)
{ {
uint8_t txbuf[2]; uint8_t txbuf[2];
txbuf[0] = (offset >> 8) & 0xff; txbuf[0] = (offset >> 8) & 0xff;
txbuf[1] = offset & 0xff; txbuf[1] = offset & 0xff;
oc_i2c_write(fmc, fmc->eeprom_addr, txbuf, 2); oc_i2c_write(fmc, fmc->eeprom_addr, txbuf, 2);
oc_i2c_write(fmc, fmc->eeprom_addr, buf, size); oc_i2c_write(fmc, fmc->eeprom_addr, buf, size);
// oc_i2c_read(fmc, i2c_addr, buf, size);
return size; return size;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment