Skip to content

Commit

Permalink
net/ethoc: support big-endian register layout
Browse files Browse the repository at this point in the history
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Max Filippov authored and David S. Miller committed Sep 23, 2015
1 parent 1bb6aa5 commit 06e60e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/net/ethernet/ethoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ struct ethoc {
void __iomem *membase;
int dma_alloc;
resource_size_t io_region_size;
bool big_endian;

unsigned int num_bd;
unsigned int num_tx;
Expand Down Expand Up @@ -236,12 +237,18 @@ struct ethoc_bd {

static inline u32 ethoc_read(struct ethoc *dev, loff_t offset)
{
return ioread32(dev->iobase + offset);
if (dev->big_endian)
return ioread32be(dev->iobase + offset);
else
return ioread32(dev->iobase + offset);
}

static inline void ethoc_write(struct ethoc *dev, loff_t offset, u32 data)
{
iowrite32(data, dev->iobase + offset);
if (dev->big_endian)
iowrite32be(data, dev->iobase + offset);
else
iowrite32(data, dev->iobase + offset);
}

static inline void ethoc_read_bd(struct ethoc *dev, int index,
Expand Down Expand Up @@ -1106,6 +1113,9 @@ static int ethoc_probe(struct platform_device *pdev)
priv->dma_alloc = buffer_size;
}

priv->big_endian = pdata ? pdata->big_endian :
of_device_is_big_endian(pdev->dev.of_node);

/* calculate the number of TX/RX buffers, maximum 128 supported */
num_bd = min_t(unsigned int,
128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ);
Expand Down
1 change: 1 addition & 0 deletions include/net/ethoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct ethoc_platform_data {
u8 hwaddr[IFHWADDRLEN];
s8 phy_id;
u32 eth_clkfreq;
bool big_endian;
};

#endif /* !LINUX_NET_ETHOC_H */
Expand Down

0 comments on commit 06e60e5

Please sign in to comment.