#include "rtl8366_smi.h"
#define RTL8366_SMI_ACK_RETRY_COUNT 5
-#define RTL8366_SMI_CLK_DELAY 10 /* nsec */
static inline void rtl8366_smi_clk_delay(struct rtl8366_smi *smi)
{
- ndelay(RTL8366_SMI_CLK_DELAY);
+ ndelay(smi->clk_delay);
}
static void rtl8366_smi_start(struct rtl8366_smi *smi)
if (ack == 0)
break;
- if (++retry_cnt > RTL8366_SMI_ACK_RETRY_COUNT)
- return -EIO;
+ if (++retry_cnt > RTL8366_SMI_ACK_RETRY_COUNT) {
+ dev_err(smi->parent, "ACK timeout\n");
+ return -ETIMEDOUT;
+ }
} while (1);
return 0;
rtl8366_smi_start(smi);
/* send READ command */
- ret = rtl8366_smi_write_byte(smi, 0x0a << 4 | 0x04 << 1 | 0x01);
+ ret = rtl8366_smi_write_byte(smi, smi->cmd_read);
if (ret)
goto out;
rtl8366_smi_start(smi);
/* send WRITE command */
- ret = rtl8366_smi_write_byte(smi, 0x0a << 4 | 0x04 << 1 | 0x00);
+ ret = rtl8366_smi_write_byte(smi, smi->cmd_write);
if (ret)
goto out;