summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2011-11-18 22:18:07 +0000
committerjmcneill <jmcneill@NetBSD.org>2011-11-18 22:18:07 +0000
commit9ef3d86eaffc4de1c9c8cebfec0ef738968346d2 (patch)
treed12ce4d8687536786aa163d8aab114348329686a /sys/dev/i2c
parent8d1aaa9536e252a30d76be0fbc1edacd6495ef2e (diff)
remove Xbox support
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/files.i2c12
-rw-r--r--sys/dev/i2c/pic16lc.c290
-rw-r--r--sys/dev/i2c/xbseeprom.c171
3 files changed, 1 insertions, 472 deletions
diff --git a/sys/dev/i2c/files.i2c b/sys/dev/i2c/files.i2c
index 6596264d2eb..91e7648f1f5 100644
--- a/sys/dev/i2c/files.i2c
+++ b/sys/dev/i2c/files.i2c
@@ -1,4 +1,4 @@
-# $NetBSD: files.i2c,v 1.44 2011/10/03 22:27:23 jmcneill Exp $
+# $NetBSD: files.i2c,v 1.45 2011/11/18 22:18:08 jmcneill Exp $
obsolete defflag opt_i2cbus.h I2C_SCAN
define i2cbus { }
@@ -143,16 +143,6 @@ attach sgsmix at iic
file dev/i2c/sgsmix.c sgsmix needs-flag
defflag opt_sgsmix.h SGSMIX_DEBUG
-# Xbox PIC16LC System Management Controller
-device pic16lc: sysmon_envsys
-attach pic16lc at iic
-file dev/i2c/pic16lc.c pic16lc needs-flag
-
-# Xbox Serial EEPROM
-device xbseeprom
-attach xbseeprom at iic
-file dev/i2c/xbseeprom.c xbseeprom
-
# Memory Serial Presence Detect
attach spdmem at iic with spdmem_iic
file dev/i2c/spdmem_i2c.c spdmem_iic
diff --git a/sys/dev/i2c/pic16lc.c b/sys/dev/i2c/pic16lc.c
deleted file mode 100644
index 554fe4ea456..00000000000
--- a/sys/dev/i2c/pic16lc.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/* $NetBSD: pic16lc.c,v 1.18 2011/11/17 16:04:07 christos Exp $ */
-
-/*-
- * Copyright (c) 2007, 2008 Jared D. McNeill <jmcneill@invisible.ca>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Microsoft XBOX System Management Controller
- *
- * Documentation lives here:
- * http://www.xbox-linux.org/wiki/PIC
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic16lc.c,v 1.18 2011/11/17 16:04:07 christos Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-
-#include <machine/xbox.h>
-
-#include <dev/sysmon/sysmonvar.h>
-#include <dev/i2c/i2cvar.h>
-#include <dev/i2c/pic16lcreg.h>
-
-static int pic16lc_match(device_t, cfdata_t, void *);
-static void pic16lc_attach(device_t, device_t, void *);
-
-static int pic16lc_intr(void *);
-
-void pic16lc_reboot(void);
-void pic16lc_poweroff(void);
-void pic16lc_setled(uint8_t);
-
-#define XBOX_SENSOR_CPU 0
-#define XBOX_SENSOR_BOARD 1
-#define XBOX_NSENSORS 2
-
-struct pic16lc_softc {
- device_t sc_dev;
-
- i2c_tag_t sc_tag;
- i2c_addr_t sc_addr;
- void * sc_ih;
-
- envsys_data_t sc_sensor[XBOX_NSENSORS];
- struct sysmon_envsys *sc_sme;
-};
-
-static struct pic16lc_softc *pic16lc = NULL;
-
-static void pic16lc_update(struct pic16lc_softc *, envsys_data_t *);
-static void pic16lc_refresh(struct sysmon_envsys *, envsys_data_t *);
-
-static void pic16lc_write_1(struct pic16lc_softc *, uint8_t, uint8_t);
-static void pic16lc_read_1(struct pic16lc_softc *, uint8_t, uint8_t *);
-
-CFATTACH_DECL_NEW(pic16lc, sizeof(struct pic16lc_softc),
- pic16lc_match, pic16lc_attach, NULL, NULL);
-
-static int
-pic16lc_match(device_t parent, cfdata_t cf, void *opaque)
-{
- struct i2c_attach_args *ia = opaque;
-
- if (pic16lc != NULL) /* we can only have one... */
- return 0;
- if (ia->ia_addr != 0x10) /* must live at 0x10 on xbox */
- return 0;
-
- return 1;
-}
-
-static void
-pic16lc_attach(device_t parent, device_t self, void *opaque)
-{
- struct pic16lc_softc *sc = device_private(self);
- struct i2c_attach_args *ia = opaque;
- u_char ver[4];
- int i;
-
- sc->sc_dev = self;
- sc->sc_tag = ia->ia_tag;
- sc->sc_addr = ia->ia_addr;
-
- pic16lc = sc;
-
- sc->sc_sme = sysmon_envsys_create();
-
- /* initialize CPU sensor */
- sc->sc_sensor[XBOX_SENSOR_CPU].units = ENVSYS_STEMP;
- sc->sc_sensor[XBOX_SENSOR_CPU].state = ENVSYS_SINVALID;
- (void)strlcpy(sc->sc_sensor[XBOX_SENSOR_CPU].desc, "Xbox CPU Temp",
- sizeof(sc->sc_sensor[XBOX_SENSOR_CPU]));
- /* initialize board sensor */
- sc->sc_sensor[XBOX_SENSOR_BOARD].units = ENVSYS_STEMP;
- sc->sc_sensor[XBOX_SENSOR_BOARD].state = ENVSYS_SINVALID;
- (void)strlcpy(sc->sc_sensor[XBOX_SENSOR_BOARD].desc, "Xbox Board Temp",
- sizeof(sc->sc_sensor[XBOX_SENSOR_BOARD]));
-
- for (i = 0; i < XBOX_NSENSORS; i++) {
- if (sysmon_envsys_sensor_attach(sc->sc_sme,
- &sc->sc_sensor[i])) {
- sysmon_envsys_destroy(sc->sc_sme);
- return;
- }
- }
-
- /* hook into sysmon */
- sc->sc_sme->sme_name = device_xname(sc->sc_dev);
- sc->sc_sme->sme_cookie = sc;
- sc->sc_sme->sme_refresh = pic16lc_refresh;
-
- if (sysmon_envsys_register(sc->sc_sme)) {
- aprint_error_dev(self, "unable to register with sysmon\n");
- sysmon_envsys_destroy(sc->sc_sme);
- return;
- }
-
- if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
- aprint_error(": unable to acquire i2c bus\n");
- return;
- }
-
- aprint_normal(": Xbox System Management Controller");
-
- /* find the PIC version */
- pic16lc_write_1(sc, PIC16LC_REG_VER, 0x00);
- pic16lc_read_1(sc, PIC16LC_REG_VER, &ver[0]);
- pic16lc_read_1(sc, PIC16LC_REG_VER, &ver[1]);
- pic16lc_read_1(sc, PIC16LC_REG_VER, &ver[2]);
- ver[3] = '\0';
-
- aprint_normal(" (rev. %s)\n", ver);
-
- pic16lc_setled(0xff); /* orange */
-
- iic_release_bus(sc->sc_tag, 0);
-
- /* disable reset on eject */
- pic16lc_write_1(sc, PIC16LC_REG_RESETONEJECT, 0x01);
-
- sc->sc_ih = iic_smbus_intr_establish_proc(sc->sc_tag, pic16lc_intr, sc);
- if (sc->sc_ih == NULL)
- aprint_error_dev(self, "couldn't establish interrupt\n");
-
- return;
-}
-
-static void
-pic16lc_write_1(struct pic16lc_softc *sc, uint8_t cmd, uint8_t val)
-{
- iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
- sc->sc_addr, &cmd, 1, &val, 1, 0);
-}
-
-static void
-pic16lc_read_1(struct pic16lc_softc *sc, uint8_t cmd, uint8_t *valp)
-{
- iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, 1, valp, 1, 0);
-}
-
-static void
-pic16lc_update(struct pic16lc_softc *sc, envsys_data_t *edata)
-{
- uint8_t temp, sensor;
-
- switch (edata->sensor) {
- case XBOX_SENSOR_CPU:
- sensor = PIC16LC_REG_CPUTEMP;
- break;
- case XBOX_SENSOR_BOARD:
- sensor = PIC16LC_REG_BOARDTEMP;
- break;
- default:
- aprint_error(": invalid sensor %u\n", edata->sensor);
- return;
- }
-
- if (iic_acquire_bus(sc->sc_tag, 0) != 0) {
- aprint_error(": unable to acquire i2c bus\n");
- return;
- }
-
- pic16lc_read_1(sc, sensor, &temp);
- edata->state = ENVSYS_SVALID;
- edata->value_cur = (unsigned int)temp * 1000000 + 273150000;
-
- iic_release_bus(sc->sc_tag, 0);
-
- return;
-}
-
-static void
-pic16lc_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
-{
- struct pic16lc_softc *sc = sme->sme_cookie;
-
- pic16lc_update(sc, edata);
-}
-
-static int
-pic16lc_intr(void *opaque)
-{
- struct pic16lc_softc *sc = opaque;
- uint8_t val;
- int rv = 0;
-
- pic16lc_read_1(sc, PIC16LC_REG_INTSTATUS, &val);
- if (val == 0)
- return rv;
-
- if (val & PIC16LC_REG_INTSTATUS_POWER)
- aprint_normal_dev(sc->sc_dev, "power button pressed\n");
- if (val & PIC16LC_REG_INTSTATUS_TRAYCLOSED)
- aprint_normal_dev(sc->sc_dev, "tray closed\n");
- if (val & PIC16LC_REG_INTSTATUS_TRAYOPENING) {
- aprint_normal_dev(sc->sc_dev, "tray opening\n");
- pic16lc_write_1(sc, PIC16LC_REG_INTACK, 0x02);
- }
- if (val & PIC16LC_REG_INTSTATUS_AVPACK_UNPLUG)
- aprint_normal_dev(sc->sc_dev, "A/V pack removed\n");
- if (val & PIC16LC_REG_INTSTATUS_AVPACK_PLUG)
- aprint_normal_dev(sc->sc_dev, "A/V pack inserted\n");
- if (val & PIC16LC_REG_INTSTATUS_EJECT_BUTTON) {
- pic16lc_write_1(sc, PIC16LC_REG_INTACK, 0x04);
- pic16lc_write_1(sc, PIC16LC_REG_TRAYEJECT, 0x00);
- ++rv;
- }
- if (val & PIC16LC_REG_INTSTATUS_TRAYCLOSING)
- aprint_normal_dev(sc->sc_dev, "tray closing\n");
-
- return rv;
-}
-
-void
-pic16lc_reboot(void)
-{
- if (pic16lc == NULL) {
- printf("pic16lc_reboot: driver not attached!\n");
- return;
- }
- pic16lc_write_1(pic16lc, PIC16LC_REG_POWER, PIC16LC_REG_POWER_RESET);
-}
-
-void
-pic16lc_poweroff(void)
-{
- if (pic16lc == NULL) {
- printf("pic16lc_poweroff: driver not attached!\n");
- return;
- }
- pic16lc_write_1(pic16lc, PIC16LC_REG_POWER, PIC16LC_REG_POWER_SHUTDOWN);
-}
-
-void
-pic16lc_setled(uint8_t val)
-{
- if (pic16lc == NULL) {
- printf("pic16lc_setled: driver not attached!\n");
- return;
- }
- pic16lc_write_1(pic16lc, PIC16LC_REG_LEDSEQ, val);
- pic16lc_write_1(pic16lc, PIC16LC_REG_LEDMODE, 0x01);
-}
diff --git a/sys/dev/i2c/xbseeprom.c b/sys/dev/i2c/xbseeprom.c
deleted file mode 100644
index 08c7b17a89e..00000000000
--- a/sys/dev/i2c/xbseeprom.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* $NetBSD: xbseeprom.c,v 1.6 2008/05/05 00:21:04 jmcneill Exp $ */
-
-/*-
- * Copyright (c) 2007, 2008 Jared D. McNeill <jmcneill@invisible.ca>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Microsoft XBOX Serial EEPROM
- *
- * Documentation lives here:
- * http://www.xbox-linux.org/wiki/Xbox_Serial_EEPROM
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbseeprom.c,v 1.6 2008/05/05 00:21:04 jmcneill Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/kmem.h>
-#include <sys/sysctl.h>
-
-#include <dev/i2c/i2cvar.h>
-
-static int xbseeprom_match(device_t, cfdata_t, void *);
-static void xbseeprom_attach(device_t, device_t, void *);
-
-struct xbseeprom_data {
- /* factory settings */
- uint8_t HMAC_SHA1_Hash[20];
- uint8_t Confounder[8];
- uint8_t HDDKkey[16];
- uint8_t XBERegion[4];
- uint8_t Checksum2[4];
- uint8_t SerialNumber[12];
- uint8_t MACAddress[6];
- uint8_t UNKNOWN2[2];
- uint8_t OnlineKey[16];
- uint8_t VideoStandard[4];
- uint8_t UNKNOWN3[4];
- /* user settings */
- uint8_t Checksum3[4];
- uint8_t TimeZoneBias[4];
- uint8_t TimeZoneStdName[4];
- uint8_t TimeZoneDltName[4];
- uint8_t UNKNOWN4[8];
- uint8_t TimeZoneStdDate[4];
- uint8_t TimeZoneDltDate[4];
- uint8_t UNKNOWN5[8];
- uint8_t TimeZoneStdBias[4];
- uint8_t TimeZoneDltBias[4];
- uint8_t LanguageID[4];
- uint8_t VideoFlags[4];
- uint8_t AudioFlags[4];
- uint8_t ParentalControlGames[4];
- uint8_t ParentalControlPwd[4];
- uint8_t ParentalControlMovies[4];
- uint8_t XBOXLiveIPAddress[4];
- uint8_t XBOXLiveDNS[4];
- uint8_t XBOXLiveGateway[4];
- uint8_t XBOXLiveSubnetMask[4];
- uint8_t OtherSettings[4];
- uint8_t DVDPlaybackKitZone[4];
- uint8_t UNKNOWN6[64];
-};
-
-#define XBSEEPROM_SIZE (sizeof(struct xbseeprom_data))
-
-struct xbseeprom_softc {
- device_t sc_dev;
-
- i2c_tag_t sc_tag;
- i2c_addr_t sc_addr;
-
- struct xbseeprom_data *sc_data;
-};
-
-static void xbseeprom_read_1(struct xbseeprom_softc *, uint8_t, uint8_t *);
-
-static char xbseeprom_serial[17];
-
-CFATTACH_DECL_NEW(xbseeprom, sizeof(struct xbseeprom_softc),
- xbseeprom_match, xbseeprom_attach, NULL, NULL);
-
-static int
-xbseeprom_match(device_t parent, cfdata_t cf, void *opaque)
-{
- struct i2c_attach_args *ia = opaque;
-
- /* Serial EEPROM always lives at 0x54 on Xbox */
- if (ia->ia_addr == 0x54)
- return 1;
-
- return 0;
-}
-
-static void
-xbseeprom_attach(device_t parent, device_t self, void *opaque)
-{
- struct xbseeprom_softc *sc = device_private(self);
- struct i2c_attach_args *ia = opaque;
- uint8_t *ptr;
- int i;
-
- sc->sc_dev = self;
- sc->sc_tag = ia->ia_tag;
- sc->sc_addr = ia->ia_addr;
-
- sc->sc_data = kmem_alloc(XBSEEPROM_SIZE, KM_SLEEP);
- if (sc->sc_data == NULL) {
- aprint_error(": Not enough memory to copy EEPROM\n");
- return;
- }
-
- aprint_normal(": Xbox Serial EEPROM\n");
-
- /* Read in EEPROM contents */
- ptr = (uint8_t *)sc->sc_data;
- for (i = 0; i < XBSEEPROM_SIZE; i++, ptr++)
- xbseeprom_read_1(sc, i, ptr);
-
-#if 0
- /* Display some interesting information */
- aprint_normal_dev(self, "MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
- sc->sc_data->MACAddress[0], sc->sc_data->MACAddress[1],
- sc->sc_data->MACAddress[2], sc->sc_data->MACAddress[3],
- sc->sc_data->MACAddress[4], sc->sc_data->MACAddress[5]
- );
-#endif
-
- /* Setup sysctl subtree */
- memset(xbseeprom_serial, 0, sizeof(xbseeprom_serial));
- memcpy(xbseeprom_serial, sc->sc_data->SerialNumber, 16);
-
- sysctl_createv(NULL, 0, NULL, NULL,
- 0, CTLTYPE_STRING, "xbox_serial",
- SYSCTL_DESCR("Xbox serial number"),
- NULL, 0, &xbseeprom_serial, 0,
- CTL_MACHDEP, CTL_CREATE, CTL_EOL);
-
- return;
-}
-
-static void
-xbseeprom_read_1(struct xbseeprom_softc *sc, uint8_t cmd, uint8_t *valp)
-{
- iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, 1, valp, 1, I2C_F_POLL);
-}