diff options
Diffstat (limited to 'drivers/net/ks8851.c')
-rw-r--r-- | drivers/net/ks8851.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index 237835864357..a23f739d222f 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c | |||
@@ -171,6 +171,36 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | /** | 173 | /** |
174 | * ks8851_wrreg8 - write 8bit register value to chip | ||
175 | * @ks: The chip state | ||
176 | * @reg: The register address | ||
177 | * @val: The value to write | ||
178 | * | ||
179 | * Issue a write to put the value @val into the register specified in @reg. | ||
180 | */ | ||
181 | static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val) | ||
182 | { | ||
183 | struct spi_transfer *xfer = &ks->spi_xfer1; | ||
184 | struct spi_message *msg = &ks->spi_msg1; | ||
185 | __le16 txb[2]; | ||
186 | int ret; | ||
187 | int bit; | ||
188 | |||
189 | bit = 1 << (reg & 3); | ||
190 | |||
191 | txb[0] = cpu_to_le16(MK_OP(bit, reg) | KS_SPIOP_WR); | ||
192 | txb[1] = val; | ||
193 | |||
194 | xfer->tx_buf = txb; | ||
195 | xfer->rx_buf = NULL; | ||
196 | xfer->len = 3; | ||
197 | |||
198 | ret = spi_sync(ks->spidev, msg); | ||
199 | if (ret < 0) | ||
200 | ks_err(ks, "spi_sync() failed\n"); | ||
201 | } | ||
202 | |||
203 | /** | ||
174 | * ks8851_rx_1msg - select whether to use one or two messages for spi read | 204 | * ks8851_rx_1msg - select whether to use one or two messages for spi read |
175 | * @ks: The device structure | 205 | * @ks: The device structure |
176 | * | 206 | * |
@@ -322,13 +352,12 @@ static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op) | |||
322 | static int ks8851_write_mac_addr(struct net_device *dev) | 352 | static int ks8851_write_mac_addr(struct net_device *dev) |
323 | { | 353 | { |
324 | struct ks8851_net *ks = netdev_priv(dev); | 354 | struct ks8851_net *ks = netdev_priv(dev); |
325 | u16 *mcp = (u16 *)dev->dev_addr; | 355 | int i; |
326 | 356 | ||
327 | mutex_lock(&ks->lock); | 357 | mutex_lock(&ks->lock); |
328 | 358 | ||
329 | ks8851_wrreg16(ks, KS_MARL, mcp[0]); | 359 | for (i = 0; i < ETH_ALEN; i++) |
330 | ks8851_wrreg16(ks, KS_MARM, mcp[1]); | 360 | ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]); |
331 | ks8851_wrreg16(ks, KS_MARH, mcp[2]); | ||
332 | 361 | ||
333 | mutex_unlock(&ks->lock); | 362 | mutex_unlock(&ks->lock); |
334 | 363 | ||
@@ -951,7 +980,7 @@ static void ks8851_set_rx_mode(struct net_device *dev) | |||
951 | mcptr = mcptr->next; | 980 | mcptr = mcptr->next; |
952 | } | 981 | } |
953 | 982 | ||
954 | rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXAE | RXCR1_RXPAFMA; | 983 | rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA; |
955 | } else { | 984 | } else { |
956 | /* just accept broadcast / unicast */ | 985 | /* just accept broadcast / unicast */ |
957 | rxctrl.rxcr1 = RXCR1_RXPAFMA; | 986 | rxctrl.rxcr1 = RXCR1_RXPAFMA; |
@@ -1239,6 +1268,9 @@ static int __devinit ks8851_probe(struct spi_device *spi) | |||
1239 | ndev->netdev_ops = &ks8851_netdev_ops; | 1268 | ndev->netdev_ops = &ks8851_netdev_ops; |
1240 | ndev->irq = spi->irq; | 1269 | ndev->irq = spi->irq; |
1241 | 1270 | ||
1271 | /* issue a global soft reset to reset the device. */ | ||
1272 | ks8851_soft_reset(ks, GRR_GSR); | ||
1273 | |||
1242 | /* simple check for a valid chip being connected to the bus */ | 1274 | /* simple check for a valid chip being connected to the bus */ |
1243 | 1275 | ||
1244 | if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { | 1276 | if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { |