16fc7f77fSKONRAD Frederic /* 2e0dadc1eSPeter Maydell * auxbus.c 36fc7f77fSKONRAD Frederic * 46fc7f77fSKONRAD Frederic * Copyright 2015 : GreenSocs Ltd 56fc7f77fSKONRAD Frederic * http://www.greensocs.com/ , email: info@greensocs.com 66fc7f77fSKONRAD Frederic * 76fc7f77fSKONRAD Frederic * Developed by : 86fc7f77fSKONRAD Frederic * Frederic Konrad <fred.konrad@greensocs.com> 96fc7f77fSKONRAD Frederic * 106fc7f77fSKONRAD Frederic * This program is free software; you can redistribute it and/or modify 116fc7f77fSKONRAD Frederic * it under the terms of the GNU General Public License as published by 126fc7f77fSKONRAD Frederic * the Free Software Foundation, either version 2 of the License, or 136fc7f77fSKONRAD Frederic * (at your option)any later version. 146fc7f77fSKONRAD Frederic * 156fc7f77fSKONRAD Frederic * This program is distributed in the hope that it will be useful, 166fc7f77fSKONRAD Frederic * but WITHOUT ANY WARRANTY; without even the implied warranty of 176fc7f77fSKONRAD Frederic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 186fc7f77fSKONRAD Frederic * GNU General Public License for more details. 196fc7f77fSKONRAD Frederic * 206fc7f77fSKONRAD Frederic * You should have received a copy of the GNU General Public License along 216fc7f77fSKONRAD Frederic * with this program; if not, see <http://www.gnu.org/licenses/>. 226fc7f77fSKONRAD Frederic * 236fc7f77fSKONRAD Frederic */ 246fc7f77fSKONRAD Frederic 256fc7f77fSKONRAD Frederic /* 266fc7f77fSKONRAD Frederic * This is an implementation of the AUX bus for VESA Display Port v1.1a. 276fc7f77fSKONRAD Frederic */ 286fc7f77fSKONRAD Frederic 296fc7f77fSKONRAD Frederic #include "qemu/osdep.h" 30de9b602eSPhilippe Mathieu-Daudé #include "qemu/units.h" 316fc7f77fSKONRAD Frederic #include "qemu/log.h" 320b8fa32fSMarkus Armbruster #include "qemu/module.h" 33e0dadc1eSPeter Maydell #include "hw/misc/auxbus.h" 346fc7f77fSKONRAD Frederic #include "hw/i2c/i2c.h" 356fc7f77fSKONRAD Frederic #include "monitor/monitor.h" 36fe04f0b4SPaolo Bonzini #include "qapi/error.h" 376fc7f77fSKONRAD Frederic 386fc7f77fSKONRAD Frederic #ifndef DEBUG_AUX 396fc7f77fSKONRAD Frederic #define DEBUG_AUX 0 406fc7f77fSKONRAD Frederic #endif 416fc7f77fSKONRAD Frederic 426fc7f77fSKONRAD Frederic #define DPRINTF(fmt, ...) do { \ 436fc7f77fSKONRAD Frederic if (DEBUG_AUX) { \ 446fc7f77fSKONRAD Frederic qemu_log("aux: " fmt , ## __VA_ARGS__); \ 456fc7f77fSKONRAD Frederic } \ 462562755eSEric Blake } while (0) 476fc7f77fSKONRAD Frederic 486fc7f77fSKONRAD Frederic 496fc7f77fSKONRAD Frederic static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent); 506fc7f77fSKONRAD Frederic static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge); 516fc7f77fSKONRAD Frederic 526fc7f77fSKONRAD Frederic /* aux-bus implementation (internal not public) */ 536fc7f77fSKONRAD Frederic static void aux_bus_class_init(ObjectClass *klass, void *data) 546fc7f77fSKONRAD Frederic { 556fc7f77fSKONRAD Frederic BusClass *k = BUS_CLASS(klass); 566fc7f77fSKONRAD Frederic 576fc7f77fSKONRAD Frederic /* AUXSlave has an MMIO so we need to change the way we print information 586fc7f77fSKONRAD Frederic * in monitor. 596fc7f77fSKONRAD Frederic */ 606fc7f77fSKONRAD Frederic k->print_dev = aux_slave_dev_print; 616fc7f77fSKONRAD Frederic } 626fc7f77fSKONRAD Frederic 63dbe4070eSMarkus Armbruster AUXBus *aux_bus_init(DeviceState *parent, const char *name) 646fc7f77fSKONRAD Frederic { 656fc7f77fSKONRAD Frederic AUXBus *bus; 66fe04f0b4SPaolo Bonzini Object *auxtoi2c; 676fc7f77fSKONRAD Frederic 686fc7f77fSKONRAD Frederic bus = AUX_BUS(qbus_create(TYPE_AUX_BUS, parent, name)); 69fe04f0b4SPaolo Bonzini auxtoi2c = object_new_with_props(TYPE_AUXTOI2C, OBJECT(bus), "i2c", 70fe04f0b4SPaolo Bonzini &error_abort, NULL); 71fe04f0b4SPaolo Bonzini 72fe04f0b4SPaolo Bonzini bus->bridge = AUXTOI2C(auxtoi2c); 736fc7f77fSKONRAD Frederic 746fc7f77fSKONRAD Frederic /* Memory related. */ 756fc7f77fSKONRAD Frederic bus->aux_io = g_malloc(sizeof(*bus->aux_io)); 76de9b602eSPhilippe Mathieu-Daudé memory_region_init(bus->aux_io, OBJECT(bus), "aux-io", 1 * MiB); 776fc7f77fSKONRAD Frederic address_space_init(&bus->aux_addr_space, bus->aux_io, "aux-io"); 786fc7f77fSKONRAD Frederic return bus; 796fc7f77fSKONRAD Frederic } 806fc7f77fSKONRAD Frederic 81b7a1b548SMarkus Armbruster void aux_bus_realize(AUXBus *bus) 82b7a1b548SMarkus Armbruster { 8322149854SMarkus Armbruster qdev_realize(DEVICE(bus->bridge), BUS(bus), &error_fatal); 84b7a1b548SMarkus Armbruster } 85b7a1b548SMarkus Armbruster 86fe04f0b4SPaolo Bonzini void aux_map_slave(AUXSlave *aux_dev, hwaddr addr) 876fc7f77fSKONRAD Frederic { 88fe04f0b4SPaolo Bonzini DeviceState *dev = DEVICE(aux_dev); 89fe04f0b4SPaolo Bonzini AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev)); 90fe04f0b4SPaolo Bonzini memory_region_add_subregion(bus->aux_io, addr, aux_dev->mmio); 916fc7f77fSKONRAD Frederic } 926fc7f77fSKONRAD Frederic 936fc7f77fSKONRAD Frederic static bool aux_bus_is_bridge(AUXBus *bus, DeviceState *dev) 946fc7f77fSKONRAD Frederic { 956fc7f77fSKONRAD Frederic return (dev == DEVICE(bus->bridge)); 966fc7f77fSKONRAD Frederic } 976fc7f77fSKONRAD Frederic 986fc7f77fSKONRAD Frederic I2CBus *aux_get_i2c_bus(AUXBus *bus) 996fc7f77fSKONRAD Frederic { 1006fc7f77fSKONRAD Frederic return aux_bridge_get_i2c_bus(bus->bridge); 1016fc7f77fSKONRAD Frederic } 1026fc7f77fSKONRAD Frederic 1036fc7f77fSKONRAD Frederic AUXReply aux_request(AUXBus *bus, AUXCommand cmd, uint32_t address, 1046fc7f77fSKONRAD Frederic uint8_t len, uint8_t *data) 1056fc7f77fSKONRAD Frederic { 1066fc7f77fSKONRAD Frederic AUXReply ret = AUX_NACK; 1076fc7f77fSKONRAD Frederic I2CBus *i2c_bus = aux_get_i2c_bus(bus); 1086fc7f77fSKONRAD Frederic size_t i; 1096fc7f77fSKONRAD Frederic bool is_write = false; 1106fc7f77fSKONRAD Frederic 1116fc7f77fSKONRAD Frederic DPRINTF("request at address 0x%" PRIX32 ", command %u, len %u\n", address, 1126fc7f77fSKONRAD Frederic cmd, len); 1136fc7f77fSKONRAD Frederic 1146fc7f77fSKONRAD Frederic switch (cmd) { 1156fc7f77fSKONRAD Frederic /* 1166fc7f77fSKONRAD Frederic * Forward the request on the AUX bus.. 1176fc7f77fSKONRAD Frederic */ 1186fc7f77fSKONRAD Frederic case WRITE_AUX: 1196fc7f77fSKONRAD Frederic case READ_AUX: 1206fc7f77fSKONRAD Frederic is_write = cmd == READ_AUX ? false : true; 1216fc7f77fSKONRAD Frederic for (i = 0; i < len; i++) { 1226fc7f77fSKONRAD Frederic if (!address_space_rw(&bus->aux_addr_space, address++, 1236fc7f77fSKONRAD Frederic MEMTXATTRS_UNSPECIFIED, data++, 1, 1246fc7f77fSKONRAD Frederic is_write)) { 1256fc7f77fSKONRAD Frederic ret = AUX_I2C_ACK; 1266fc7f77fSKONRAD Frederic } else { 1276fc7f77fSKONRAD Frederic ret = AUX_NACK; 1286fc7f77fSKONRAD Frederic break; 1296fc7f77fSKONRAD Frederic } 1306fc7f77fSKONRAD Frederic } 1316fc7f77fSKONRAD Frederic break; 1326fc7f77fSKONRAD Frederic /* 1336fc7f77fSKONRAD Frederic * Classic I2C transactions.. 1346fc7f77fSKONRAD Frederic */ 1356fc7f77fSKONRAD Frederic case READ_I2C: 136*80675e19SPhilippe Mathieu-Daudé is_write = cmd == READ_I2C ? false : true; 137*80675e19SPhilippe Mathieu-Daudé if (i2c_bus_busy(i2c_bus)) { 138*80675e19SPhilippe Mathieu-Daudé i2c_end_transfer(i2c_bus); 139*80675e19SPhilippe Mathieu-Daudé } 140*80675e19SPhilippe Mathieu-Daudé 141*80675e19SPhilippe Mathieu-Daudé if (i2c_start_transfer(i2c_bus, address, !is_write)) { 142*80675e19SPhilippe Mathieu-Daudé ret = AUX_I2C_NACK; 143*80675e19SPhilippe Mathieu-Daudé break; 144*80675e19SPhilippe Mathieu-Daudé } 145*80675e19SPhilippe Mathieu-Daudé 146*80675e19SPhilippe Mathieu-Daudé ret = AUX_I2C_ACK; 147*80675e19SPhilippe Mathieu-Daudé while (len > 0) { 148*80675e19SPhilippe Mathieu-Daudé if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { 149*80675e19SPhilippe Mathieu-Daudé ret = AUX_I2C_NACK; 150*80675e19SPhilippe Mathieu-Daudé break; 151*80675e19SPhilippe Mathieu-Daudé } 152*80675e19SPhilippe Mathieu-Daudé len--; 153*80675e19SPhilippe Mathieu-Daudé } 154*80675e19SPhilippe Mathieu-Daudé i2c_end_transfer(i2c_bus); 155*80675e19SPhilippe Mathieu-Daudé break; 1566fc7f77fSKONRAD Frederic case WRITE_I2C: 1576fc7f77fSKONRAD Frederic is_write = cmd == READ_I2C ? false : true; 1586fc7f77fSKONRAD Frederic if (i2c_bus_busy(i2c_bus)) { 1596fc7f77fSKONRAD Frederic i2c_end_transfer(i2c_bus); 1606fc7f77fSKONRAD Frederic } 1616fc7f77fSKONRAD Frederic 162eb837738SPhilippe Mathieu-Daudé if (i2c_start_transfer(i2c_bus, address, !is_write)) { 1636fc7f77fSKONRAD Frederic ret = AUX_I2C_NACK; 1646fc7f77fSKONRAD Frederic break; 1656fc7f77fSKONRAD Frederic } 1666fc7f77fSKONRAD Frederic 1676fc7f77fSKONRAD Frederic ret = AUX_I2C_ACK; 1686fc7f77fSKONRAD Frederic while (len > 0) { 1696fc7f77fSKONRAD Frederic if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { 1706fc7f77fSKONRAD Frederic ret = AUX_I2C_NACK; 1716fc7f77fSKONRAD Frederic break; 1726fc7f77fSKONRAD Frederic } 1736fc7f77fSKONRAD Frederic len--; 1746fc7f77fSKONRAD Frederic } 1756fc7f77fSKONRAD Frederic i2c_end_transfer(i2c_bus); 1766fc7f77fSKONRAD Frederic break; 1776fc7f77fSKONRAD Frederic /* 1786fc7f77fSKONRAD Frederic * I2C MOT transactions. 1796fc7f77fSKONRAD Frederic * 1806fc7f77fSKONRAD Frederic * Here we send a start when: 1816fc7f77fSKONRAD Frederic * - We didn't start transaction yet. 1826fc7f77fSKONRAD Frederic * - We had a READ and we do a WRITE. 1836fc7f77fSKONRAD Frederic * - We changed the address. 1846fc7f77fSKONRAD Frederic */ 1856fc7f77fSKONRAD Frederic case WRITE_I2C_MOT: 186*80675e19SPhilippe Mathieu-Daudé is_write = cmd == READ_I2C_MOT ? false : true; 187*80675e19SPhilippe Mathieu-Daudé ret = AUX_I2C_NACK; 188*80675e19SPhilippe Mathieu-Daudé if (!i2c_bus_busy(i2c_bus)) { 189*80675e19SPhilippe Mathieu-Daudé /* 190*80675e19SPhilippe Mathieu-Daudé * No transactions started.. 191*80675e19SPhilippe Mathieu-Daudé */ 192*80675e19SPhilippe Mathieu-Daudé if (i2c_start_transfer(i2c_bus, address, !is_write)) { 193*80675e19SPhilippe Mathieu-Daudé break; 194*80675e19SPhilippe Mathieu-Daudé } 195*80675e19SPhilippe Mathieu-Daudé } else if ((address != bus->last_i2c_address) || 196*80675e19SPhilippe Mathieu-Daudé (bus->last_transaction != cmd)) { 197*80675e19SPhilippe Mathieu-Daudé /* 198*80675e19SPhilippe Mathieu-Daudé * Transaction started but we need to restart.. 199*80675e19SPhilippe Mathieu-Daudé */ 200*80675e19SPhilippe Mathieu-Daudé i2c_end_transfer(i2c_bus); 201*80675e19SPhilippe Mathieu-Daudé if (i2c_start_transfer(i2c_bus, address, !is_write)) { 202*80675e19SPhilippe Mathieu-Daudé break; 203*80675e19SPhilippe Mathieu-Daudé } 204*80675e19SPhilippe Mathieu-Daudé } 205*80675e19SPhilippe Mathieu-Daudé 206*80675e19SPhilippe Mathieu-Daudé bus->last_transaction = cmd; 207*80675e19SPhilippe Mathieu-Daudé bus->last_i2c_address = address; 208*80675e19SPhilippe Mathieu-Daudé while (len > 0) { 209*80675e19SPhilippe Mathieu-Daudé if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { 210*80675e19SPhilippe Mathieu-Daudé i2c_end_transfer(i2c_bus); 211*80675e19SPhilippe Mathieu-Daudé break; 212*80675e19SPhilippe Mathieu-Daudé } 213*80675e19SPhilippe Mathieu-Daudé len--; 214*80675e19SPhilippe Mathieu-Daudé } 215*80675e19SPhilippe Mathieu-Daudé if (len == 0) { 216*80675e19SPhilippe Mathieu-Daudé ret = AUX_I2C_ACK; 217*80675e19SPhilippe Mathieu-Daudé } 218*80675e19SPhilippe Mathieu-Daudé break; 2196fc7f77fSKONRAD Frederic case READ_I2C_MOT: 2206fc7f77fSKONRAD Frederic is_write = cmd == READ_I2C_MOT ? false : true; 2215229f45bSPaolo Bonzini ret = AUX_I2C_NACK; 2226fc7f77fSKONRAD Frederic if (!i2c_bus_busy(i2c_bus)) { 2236fc7f77fSKONRAD Frederic /* 2246fc7f77fSKONRAD Frederic * No transactions started.. 2256fc7f77fSKONRAD Frederic */ 226eb837738SPhilippe Mathieu-Daudé if (i2c_start_transfer(i2c_bus, address, !is_write)) { 2276fc7f77fSKONRAD Frederic break; 2286fc7f77fSKONRAD Frederic } 2296fc7f77fSKONRAD Frederic } else if ((address != bus->last_i2c_address) || 2306fc7f77fSKONRAD Frederic (bus->last_transaction != cmd)) { 2316fc7f77fSKONRAD Frederic /* 2326fc7f77fSKONRAD Frederic * Transaction started but we need to restart.. 2336fc7f77fSKONRAD Frederic */ 2346fc7f77fSKONRAD Frederic i2c_end_transfer(i2c_bus); 235eb837738SPhilippe Mathieu-Daudé if (i2c_start_transfer(i2c_bus, address, !is_write)) { 2366fc7f77fSKONRAD Frederic break; 2376fc7f77fSKONRAD Frederic } 2386fc7f77fSKONRAD Frederic } 2396fc7f77fSKONRAD Frederic 2405229f45bSPaolo Bonzini bus->last_transaction = cmd; 2415229f45bSPaolo Bonzini bus->last_i2c_address = address; 2426fc7f77fSKONRAD Frederic while (len > 0) { 2436fc7f77fSKONRAD Frederic if (i2c_send_recv(i2c_bus, data++, is_write) < 0) { 2446fc7f77fSKONRAD Frederic i2c_end_transfer(i2c_bus); 2456fc7f77fSKONRAD Frederic break; 2466fc7f77fSKONRAD Frederic } 2476fc7f77fSKONRAD Frederic len--; 2486fc7f77fSKONRAD Frederic } 2495229f45bSPaolo Bonzini if (len == 0) { 2506fc7f77fSKONRAD Frederic ret = AUX_I2C_ACK; 2515229f45bSPaolo Bonzini } 2526fc7f77fSKONRAD Frederic break; 2536fc7f77fSKONRAD Frederic default: 254d263425bSPhilippe Mathieu-Daudé qemu_log_mask(LOG_UNIMP, "AUX cmd=%u not implemented\n", cmd); 2556fc7f77fSKONRAD Frederic return AUX_NACK; 2566fc7f77fSKONRAD Frederic } 2576fc7f77fSKONRAD Frederic 2586fc7f77fSKONRAD Frederic DPRINTF("reply: %u\n", ret); 2596fc7f77fSKONRAD Frederic return ret; 2606fc7f77fSKONRAD Frederic } 2616fc7f77fSKONRAD Frederic 2626fc7f77fSKONRAD Frederic static const TypeInfo aux_bus_info = { 2636fc7f77fSKONRAD Frederic .name = TYPE_AUX_BUS, 2646fc7f77fSKONRAD Frederic .parent = TYPE_BUS, 2656fc7f77fSKONRAD Frederic .instance_size = sizeof(AUXBus), 2666fc7f77fSKONRAD Frederic .class_init = aux_bus_class_init 2676fc7f77fSKONRAD Frederic }; 2686fc7f77fSKONRAD Frederic 2696fc7f77fSKONRAD Frederic /* aux-i2c implementation (internal not public) */ 2706fc7f77fSKONRAD Frederic struct AUXTOI2CState { 2716fc7f77fSKONRAD Frederic /*< private >*/ 2726fc7f77fSKONRAD Frederic DeviceState parent_obj; 2736fc7f77fSKONRAD Frederic 2746fc7f77fSKONRAD Frederic /*< public >*/ 2756fc7f77fSKONRAD Frederic I2CBus *i2c_bus; 2766fc7f77fSKONRAD Frederic }; 2776fc7f77fSKONRAD Frederic 278b9710bc9SKONRAD Frederic static void aux_bridge_class_init(ObjectClass *oc, void *data) 279b9710bc9SKONRAD Frederic { 280b9710bc9SKONRAD Frederic DeviceClass *dc = DEVICE_CLASS(oc); 281b9710bc9SKONRAD Frederic 282b9710bc9SKONRAD Frederic /* This device is private and is created only once for each 283dbe4070eSMarkus Armbruster * aux-bus in aux_bus_init(..). So don't allow the user to add one. 284b9710bc9SKONRAD Frederic */ 285b9710bc9SKONRAD Frederic dc->user_creatable = false; 286b9710bc9SKONRAD Frederic } 287b9710bc9SKONRAD Frederic 2886fc7f77fSKONRAD Frederic static void aux_bridge_init(Object *obj) 2896fc7f77fSKONRAD Frederic { 2906fc7f77fSKONRAD Frederic AUXTOI2CState *s = AUXTOI2C(obj); 2916fc7f77fSKONRAD Frederic 2926fc7f77fSKONRAD Frederic s->i2c_bus = i2c_init_bus(DEVICE(obj), "aux-i2c"); 2936fc7f77fSKONRAD Frederic } 2946fc7f77fSKONRAD Frederic 2956fc7f77fSKONRAD Frederic static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge) 2966fc7f77fSKONRAD Frederic { 2976fc7f77fSKONRAD Frederic return bridge->i2c_bus; 2986fc7f77fSKONRAD Frederic } 2996fc7f77fSKONRAD Frederic 3006fc7f77fSKONRAD Frederic static const TypeInfo aux_to_i2c_type_info = { 3016fc7f77fSKONRAD Frederic .name = TYPE_AUXTOI2C, 3026b888ee2SMarkus Armbruster .parent = TYPE_AUX_SLAVE, 303b9710bc9SKONRAD Frederic .class_init = aux_bridge_class_init, 3046fc7f77fSKONRAD Frederic .instance_size = sizeof(AUXTOI2CState), 3056fc7f77fSKONRAD Frederic .instance_init = aux_bridge_init 3066fc7f77fSKONRAD Frederic }; 3076fc7f77fSKONRAD Frederic 3086fc7f77fSKONRAD Frederic /* aux-slave implementation */ 3096fc7f77fSKONRAD Frederic static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent) 3106fc7f77fSKONRAD Frederic { 3116fc7f77fSKONRAD Frederic AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev)); 3126fc7f77fSKONRAD Frederic AUXSlave *s; 3136fc7f77fSKONRAD Frederic 3146fc7f77fSKONRAD Frederic /* Don't print anything if the device is I2C "bridge". */ 3156fc7f77fSKONRAD Frederic if (aux_bus_is_bridge(bus, dev)) { 3166fc7f77fSKONRAD Frederic return; 3176fc7f77fSKONRAD Frederic } 3186fc7f77fSKONRAD Frederic 3196fc7f77fSKONRAD Frederic s = AUX_SLAVE(dev); 3206fc7f77fSKONRAD Frederic 3216fc7f77fSKONRAD Frederic monitor_printf(mon, "%*smemory " TARGET_FMT_plx "/" TARGET_FMT_plx "\n", 3226fc7f77fSKONRAD Frederic indent, "", 3231eb42434SMarc-André Lureau object_property_get_uint(OBJECT(s->mmio), "addr", NULL), 3246fc7f77fSKONRAD Frederic memory_region_size(s->mmio)); 3256fc7f77fSKONRAD Frederic } 3266fc7f77fSKONRAD Frederic 3276fc7f77fSKONRAD Frederic void aux_init_mmio(AUXSlave *aux_slave, MemoryRegion *mmio) 3286fc7f77fSKONRAD Frederic { 3296fc7f77fSKONRAD Frederic assert(!aux_slave->mmio); 3306fc7f77fSKONRAD Frederic aux_slave->mmio = mmio; 3316fc7f77fSKONRAD Frederic } 3326fc7f77fSKONRAD Frederic 3336fc7f77fSKONRAD Frederic static void aux_slave_class_init(ObjectClass *klass, void *data) 3346fc7f77fSKONRAD Frederic { 3356fc7f77fSKONRAD Frederic DeviceClass *k = DEVICE_CLASS(klass); 3366fc7f77fSKONRAD Frederic 3376fc7f77fSKONRAD Frederic set_bit(DEVICE_CATEGORY_MISC, k->categories); 3386fc7f77fSKONRAD Frederic k->bus_type = TYPE_AUX_BUS; 3396fc7f77fSKONRAD Frederic } 3406fc7f77fSKONRAD Frederic 3416fc7f77fSKONRAD Frederic static const TypeInfo aux_slave_type_info = { 3426fc7f77fSKONRAD Frederic .name = TYPE_AUX_SLAVE, 3436fc7f77fSKONRAD Frederic .parent = TYPE_DEVICE, 3446fc7f77fSKONRAD Frederic .instance_size = sizeof(AUXSlave), 3456fc7f77fSKONRAD Frederic .abstract = true, 3466fc7f77fSKONRAD Frederic .class_init = aux_slave_class_init, 3476fc7f77fSKONRAD Frederic }; 3486fc7f77fSKONRAD Frederic 3496fc7f77fSKONRAD Frederic static void aux_register_types(void) 3506fc7f77fSKONRAD Frederic { 3516fc7f77fSKONRAD Frederic type_register_static(&aux_bus_info); 3526fc7f77fSKONRAD Frederic type_register_static(&aux_slave_type_info); 3536fc7f77fSKONRAD Frederic type_register_static(&aux_to_i2c_type_info); 3546fc7f77fSKONRAD Frederic } 3556fc7f77fSKONRAD Frederic 3566fc7f77fSKONRAD Frederic type_init(aux_register_types) 357