net: sh-eth: Add invalidate cache control for rmobile (ARM SoC)
The sh-eth of rmobile needs to use invalidate_cache* function. This patch adds invalidate_cache* function. Signed-off-by: Hisashi Nakamura <hisashi.nakamura.ak@renesas.com> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> Patch: 268948
This commit is contained in:
parent
f8b7507d41
commit
92f0713408
@ -26,13 +26,30 @@
|
|||||||
# error "Please define CONFIG_SH_ETHER_PHY_ADDR"
|
# error "Please define CONFIG_SH_ETHER_PHY_ADDR"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SH_ETHER_CACHE_WRITEBACK
|
#if defined(CONFIG_SH_ETHER_CACHE_WRITEBACK) && !defined(CONFIG_SYS_DCACHE_OFF)
|
||||||
#define flush_cache_wback(addr, len) \
|
#define flush_cache_wback(addr, len) \
|
||||||
flush_dcache_range((u32)addr, (u32)(addr + len - 1))
|
flush_dcache_range((u32)addr, (u32)(addr + len - 1))
|
||||||
#else
|
#else
|
||||||
#define flush_cache_wback(...)
|
#define flush_cache_wback(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SH_ETHER_CACHE_INVALIDATE) && defined(CONFIG_ARM)
|
||||||
|
#define invalidate_cache(addr, len) \
|
||||||
|
{ \
|
||||||
|
u32 line_size = CONFIG_SH_ETHER_ALIGNE_SIZE; \
|
||||||
|
u32 start, end; \
|
||||||
|
\
|
||||||
|
start = (u32)addr; \
|
||||||
|
end = start + len; \
|
||||||
|
start &= ~(line_size - 1); \
|
||||||
|
end = ((end + line_size - 1) & ~(line_size - 1)); \
|
||||||
|
\
|
||||||
|
invalidate_dcache_range(start, end); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define invalidate_cache(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TIMEOUT_CNT 1000
|
#define TIMEOUT_CNT 1000
|
||||||
|
|
||||||
int sh_eth_send(struct eth_device *dev, void *packet, int len)
|
int sh_eth_send(struct eth_device *dev, void *packet, int len)
|
||||||
@ -70,8 +87,11 @@ int sh_eth_send(struct eth_device *dev, void *packet, int len)
|
|||||||
|
|
||||||
/* Wait until packet is transmitted */
|
/* Wait until packet is transmitted */
|
||||||
timeout = TIMEOUT_CNT;
|
timeout = TIMEOUT_CNT;
|
||||||
while (port_info->tx_desc_cur->td0 & TD_TACT && timeout--)
|
do {
|
||||||
|
invalidate_cache(port_info->tx_desc_cur,
|
||||||
|
sizeof(struct tx_desc_s));
|
||||||
udelay(100);
|
udelay(100);
|
||||||
|
} while (port_info->tx_desc_cur->td0 & TD_TACT && timeout--);
|
||||||
|
|
||||||
if (timeout < 0) {
|
if (timeout < 0) {
|
||||||
printf(SHETHER_NAME ": transmit timeout\n");
|
printf(SHETHER_NAME ": transmit timeout\n");
|
||||||
@ -95,12 +115,14 @@ int sh_eth_recv(struct eth_device *dev)
|
|||||||
uchar *packet;
|
uchar *packet;
|
||||||
|
|
||||||
/* Check if the rx descriptor is ready */
|
/* Check if the rx descriptor is ready */
|
||||||
|
invalidate_cache(port_info->rx_desc_cur, sizeof(struct rx_desc_s));
|
||||||
if (!(port_info->rx_desc_cur->rd0 & RD_RACT)) {
|
if (!(port_info->rx_desc_cur->rd0 & RD_RACT)) {
|
||||||
/* Check for errors */
|
/* Check for errors */
|
||||||
if (!(port_info->rx_desc_cur->rd0 & RD_RFE)) {
|
if (!(port_info->rx_desc_cur->rd0 & RD_RFE)) {
|
||||||
len = port_info->rx_desc_cur->rd1 & 0xffff;
|
len = port_info->rx_desc_cur->rd1 & 0xffff;
|
||||||
packet = (uchar *)
|
packet = (uchar *)
|
||||||
ADDR_TO_P2(port_info->rx_desc_cur->rd2);
|
ADDR_TO_P2(port_info->rx_desc_cur->rd2);
|
||||||
|
invalidate_cache(packet, len);
|
||||||
NetReceive(packet, len);
|
NetReceive(packet, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +131,6 @@ int sh_eth_recv(struct eth_device *dev)
|
|||||||
port_info->rx_desc_cur->rd0 = RD_RACT | RD_RDLE;
|
port_info->rx_desc_cur->rd0 = RD_RACT | RD_RDLE;
|
||||||
else
|
else
|
||||||
port_info->rx_desc_cur->rd0 = RD_RACT;
|
port_info->rx_desc_cur->rd0 = RD_RACT;
|
||||||
|
|
||||||
/* Point to the next descriptor */
|
/* Point to the next descriptor */
|
||||||
port_info->rx_desc_cur++;
|
port_info->rx_desc_cur++;
|
||||||
if (port_info->rx_desc_cur >=
|
if (port_info->rx_desc_cur >=
|
||||||
|
Loading…
Reference in New Issue
Block a user