// SPDX-License-Identifier: GPL-2.0 /* * SPI driver for Micrel/Kendin KS8995M and KSZ8864RMN ethernet switches * * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org> * * This file was based on: drivers/spi/at25.c * Copyright (C) 2006 David Brownell
*/
#define KS8995_REG_GC0 0x02 /* Global Control 0 */ #define KS8995_REG_GC1 0x03 /* Global Control 1 */ #define KS8995_REG_GC2 0x04 /* Global Control 2 */ #define KS8995_REG_GC3 0x05 /* Global Control 3 */ #define KS8995_REG_GC4 0x06 /* Global Control 4 */ #define KS8995_REG_GC5 0x07 /* Global Control 5 */ #define KS8995_REG_GC6 0x08 /* Global Control 6 */ #define KS8995_REG_GC7 0x09 /* Global Control 7 */ #define KS8995_REG_GC8 0x0a /* Global Control 8 */ #define KS8995_REG_GC9 0x0b /* Global Control 9 */
#define KS8995_REG_PC(p, r) ((0x10 * p) + r) /* Port Control */ #define KS8995_REG_PS(p, r) ((0x10 * p) + r + 0xe) /* Port Status */
#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */ #define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */ #define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */ #define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */ #define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */ #define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */ #define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */ #define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */
#define KS8995_REG_MAC0 0x68 /* MAC address 0 */ #define KS8995_REG_MAC1 0x69 /* MAC address 1 */ #define KS8995_REG_MAC2 0x6a /* MAC address 2 */ #define KS8995_REG_MAC3 0x6b /* MAC address 3 */ #define KS8995_REG_MAC4 0x6c /* MAC address 4 */ #define KS8995_REG_MAC5 0x6d /* MAC address 5 */
#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */ #define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */ #define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */ #define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */ #define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */ #define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */ #define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */ #define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */ #define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */ #define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */
#define KSZ8864_REG_ID1 0xfe /* Chip ID in bit 7 */
dev = kobj_to_dev(kobj);
ks8995 = dev_get_drvdata(dev);
return ks8995_write(ks8995, buf, off, count);
}
/* ks8995_get_revision - get chip revision * @ks: pointer to switch instance * * Verify chip family and id and get chip revision.
*/ staticint ks8995_get_revision(struct ks8995_switch *ks)
{ int err;
u8 id0, id1, ksz8864_id;
/* read family id */
err = ks8995_read_reg(ks, KS8995_REG_ID0, &id0); if (err) {
err = -EIO; goto err_out;
}
/* verify family id */ if (id0 != ks->chip->family_id) {
dev_err(&ks->spi->dev, "chip family id mismatch: expected 0x%02x but 0x%02x read\n",
ks->chip->family_id, id0);
err = -ENODEV; goto err_out;
}
switch (ks->chip->family_id) { case FAMILY_KS8995: /* try reading chip id at CHIP ID1 */
err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1); if (err) {
err = -EIO; goto err_out;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.