Commit 5e74672c authored by Philipp Zabel's avatar Philipp Zabel Committed by Pierre Ossman

tmio_mmc: add bus_shift support

Some ASIC3 devices in the wild are connected with the address bus shifted
by one line, so that its 16-bit registers appear 32-bit aligned in host
memory space.
Signed-off-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Acked-by: default avatarIan Molton <ian@mnementh.co.uk>
Signed-off-by: default avatarPierre Ossman <pierre@ossman.eu>
parent f0e46cc4
This diff is collapsed.
...@@ -83,34 +83,36 @@ ...@@ -83,34 +83,36 @@
TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT) TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT)
#define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD) #define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD)
#define enable_mmc_irqs(ctl, i) \
#define enable_mmc_irqs(host, i) \
do { \ do { \
u32 mask;\ u32 mask;\
mask = tmio_ioread32((ctl) + CTL_IRQ_MASK); \ mask = sd_ctrl_read32((host), CTL_IRQ_MASK); \
mask &= ~((i) & TMIO_MASK_IRQ); \ mask &= ~((i) & TMIO_MASK_IRQ); \
tmio_iowrite32(mask, (ctl) + CTL_IRQ_MASK); \ sd_ctrl_write32((host), CTL_IRQ_MASK, mask); \
} while (0) } while (0)
#define disable_mmc_irqs(ctl, i) \ #define disable_mmc_irqs(host, i) \
do { \ do { \
u32 mask;\ u32 mask;\
mask = tmio_ioread32((ctl) + CTL_IRQ_MASK); \ mask = sd_ctrl_read32((host), CTL_IRQ_MASK); \
mask |= ((i) & TMIO_MASK_IRQ); \ mask |= ((i) & TMIO_MASK_IRQ); \
tmio_iowrite32(mask, (ctl) + CTL_IRQ_MASK); \ sd_ctrl_write32((host), CTL_IRQ_MASK, mask); \
} while (0) } while (0)
#define ack_mmc_irqs(ctl, i) \ #define ack_mmc_irqs(host, i) \
do { \ do { \
u32 mask;\ u32 mask;\
mask = tmio_ioread32((ctl) + CTL_STATUS); \ mask = sd_ctrl_read32((host), CTL_STATUS); \
mask &= ~((i) & TMIO_MASK_IRQ); \ mask &= ~((i) & TMIO_MASK_IRQ); \
tmio_iowrite32(mask, (ctl) + CTL_STATUS); \ sd_ctrl_write32((host), CTL_STATUS, mask); \
} while (0) } while (0)
struct tmio_mmc_host { struct tmio_mmc_host {
void __iomem *cnf; void __iomem *cnf;
void __iomem *ctl; void __iomem *ctl;
unsigned long bus_shift;
struct mmc_command *cmd; struct mmc_command *cmd;
struct mmc_request *mrq; struct mmc_request *mrq;
struct mmc_data *data; struct mmc_data *data;
...@@ -123,6 +125,63 @@ struct tmio_mmc_host { ...@@ -123,6 +125,63 @@ struct tmio_mmc_host {
unsigned int sg_off; unsigned int sg_off;
}; };
#include <linux/io.h>
static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr)
{
return readw(host->ctl + (addr << host->bus_shift));
}
static inline void sd_ctrl_read16_rep(struct tmio_mmc_host *host, int addr,
u16 *buf, int count)
{
readsw(host->ctl + (addr << host->bus_shift), buf, count);
}
static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr)
{
return readw(host->ctl + (addr << host->bus_shift)) |
readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
}
static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr,
u16 val)
{
writew(val, host->ctl + (addr << host->bus_shift));
}
static inline void sd_ctrl_write16_rep(struct tmio_mmc_host *host, int addr,
u16 *buf, int count)
{
writesw(host->ctl + (addr << host->bus_shift), buf, count);
}
static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr,
u32 val)
{
writew(val, host->ctl + (addr << host->bus_shift));
writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
}
static inline void sd_config_write8(struct tmio_mmc_host *host, int addr,
u8 val)
{
writeb(val, host->cnf + (addr << host->bus_shift));
}
static inline void sd_config_write16(struct tmio_mmc_host *host, int addr,
u16 val)
{
writew(val, host->cnf + (addr << host->bus_shift));
}
static inline void sd_config_write32(struct tmio_mmc_host *host, int addr,
u32 val)
{
writew(val, host->cnf + (addr << host->bus_shift));
writew(val >> 16, host->cnf + ((addr + 2) << host->bus_shift));
}
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
......
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