On 16.05.2009 01:41, Carl-Daniel Hailfinger wrote:
Add 16 bit and 32 bit chip reads/writes to the nic3com driver. It emulates those accesses by splitting them to 8 bit accesses.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
New patch. Thanks to Uwe for the quick review on IRC. The emulation is not done in a generic function instead, which removes code from the nic3com driver.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-nic3com_16bit_32bit_read_write/flash.h =================================================================== --- flashrom-nic3com_16bit_32bit_read_write/flash.h (Revision 516) +++ flashrom-nic3com_16bit_32bit_read_write/flash.h (Arbeitskopie) @@ -611,6 +611,10 @@ uint8_t internal_chip_readb(const volatile void *addr); uint16_t internal_chip_readw(const volatile void *addr); uint32_t internal_chip_readl(const volatile void *addr); +void fallback_chip_writew(uint16_t val, volatile void *addr); +void fallback_chip_writel(uint32_t val, volatile void *addr); +uint16_t fallback_chip_readw(const volatile void *addr); +uint32_t fallback_chip_readl(const volatile void *addr); #if defined(__FreeBSD__) || defined(__DragonFly__) extern int io_fd; #endif @@ -635,11 +639,7 @@ void *nic3com_map(const char *descr, unsigned long phys_addr, size_t len); void nic3com_unmap(void *virt_addr, size_t len); void nic3com_chip_writeb(uint8_t val, volatile void *addr); -void nic3com_chip_writew(uint16_t val, volatile void *addr); -void nic3com_chip_writel(uint32_t val, volatile void *addr); uint8_t nic3com_chip_readb(const volatile void *addr); -uint16_t nic3com_chip_readw(const volatile void *addr); -uint32_t nic3com_chip_readl(const volatile void *addr); extern struct pcidev_status nics_3com[];
/* flashrom.c */ Index: flashrom-nic3com_16bit_32bit_read_write/nic3com.c =================================================================== --- flashrom-nic3com_16bit_32bit_read_write/nic3com.c (Revision 516) +++ flashrom-nic3com_16bit_32bit_read_write/nic3com.c (Arbeitskopie) @@ -93,14 +93,6 @@ OUTB(val, io_base_addr + BIOS_ROM_DATA); }
-void nic3com_chip_writew(uint16_t val, volatile void *addr) -{ -} - -void nic3com_chip_writel(uint32_t val, volatile void *addr) -{ -} - uint8_t nic3com_chip_readb(const volatile void *addr) { uint8_t val; @@ -110,13 +102,3 @@
return val; } - -uint16_t nic3com_chip_readw(const volatile void *addr) -{ - return 0xffff; -} - -uint32_t nic3com_chip_readl(const volatile void *addr) -{ - return 0xffffffff; -} Index: flashrom-nic3com_16bit_32bit_read_write/flashrom.c =================================================================== --- flashrom-nic3com_16bit_32bit_read_write/flashrom.c (Revision 516) +++ flashrom-nic3com_16bit_32bit_read_write/flashrom.c (Arbeitskopie) @@ -69,11 +69,11 @@ .map_flash_region = nic3com_map, .unmap_flash_region = nic3com_unmap, .chip_readb = nic3com_chip_readb, - .chip_readw = nic3com_chip_readw, - .chip_readl = nic3com_chip_readl, + .chip_readw = fallback_chip_readw, + .chip_readl = fallback_chip_readl, .chip_writeb = nic3com_chip_writeb, - .chip_writew = nic3com_chip_writew, - .chip_writel = nic3com_chip_writel, + .chip_writew = fallback_chip_writew, + .chip_writel = fallback_chip_writel, },
{}, Index: flashrom-nic3com_16bit_32bit_read_write/internal.c =================================================================== --- flashrom-nic3com_16bit_32bit_read_write/internal.c (Revision 516) +++ flashrom-nic3com_16bit_32bit_read_write/internal.c (Arbeitskopie) @@ -168,3 +168,34 @@ return *(volatile uint32_t *) addr; }
+/* Little-endian fallback for drivers not supporting 16 bit accesses */ +void fallback_chip_writew(uint16_t val, volatile void *addr) +{ + chip_writeb(val & 0xff, addr); + chip_writeb((val >> 8) & 0xff, addr + 1); +} + +/* Little-endian fallback for drivers not supporting 16 bit accesses */ +uint16_t fallback_chip_readw(const volatile void *addr) +{ + uint16_t val; + val = chip_readb(addr); + val |= chip_readb(addr + 1) << 8; + return val; +} + +/* Little-endian fallback for drivers not supporting 32 bit accesses */ +void fallback_chip_writel(uint32_t val, volatile void *addr) +{ + chip_writew(val & 0xffff, addr); + chip_writew((val >> 16) & 0xffff, addr + 2); +} + +/* Little-endian fallback for drivers not supporting 32 bit accesses */ +uint32_t fallback_chip_readl(const volatile void *addr) +{ + uint32_t val; + val = chip_readw(addr); + val |= chip_readw(addr + 2) << 16; + return val; +}