xref: /qemu/hw/i2c/ppc4xx_i2c.c (revision 39aeba6caa4b9de8b195fddddae5cc5835d19b04)
165ca801bSBALATON Zoltan /*
265ca801bSBALATON Zoltan  * PPC4xx I2C controller emulation
365ca801bSBALATON Zoltan  *
465ca801bSBALATON Zoltan  * Copyright (c) 2007 Jocelyn Mayer
57709dbf1SBALATON Zoltan  * Copyright (c) 2012 François Revol
6*39aeba6cSBALATON Zoltan  * Copyright (c) 2016-2018 BALATON Zoltan
765ca801bSBALATON Zoltan  *
865ca801bSBALATON Zoltan  * Permission is hereby granted, free of charge, to any person obtaining a copy
965ca801bSBALATON Zoltan  * of this software and associated documentation files (the "Software"), to deal
1065ca801bSBALATON Zoltan  * in the Software without restriction, including without limitation the rights
1165ca801bSBALATON Zoltan  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1265ca801bSBALATON Zoltan  * copies of the Software, and to permit persons to whom the Software is
1365ca801bSBALATON Zoltan  * furnished to do so, subject to the following conditions:
1465ca801bSBALATON Zoltan  *
1565ca801bSBALATON Zoltan  * The above copyright notice and this permission notice shall be included in
1665ca801bSBALATON Zoltan  * all copies or substantial portions of the Software.
1765ca801bSBALATON Zoltan  *
1865ca801bSBALATON Zoltan  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1965ca801bSBALATON Zoltan  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2065ca801bSBALATON Zoltan  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
2165ca801bSBALATON Zoltan  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2265ca801bSBALATON Zoltan  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2365ca801bSBALATON Zoltan  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2465ca801bSBALATON Zoltan  * THE SOFTWARE.
2565ca801bSBALATON Zoltan  */
2665ca801bSBALATON Zoltan 
2765ca801bSBALATON Zoltan #include "qemu/osdep.h"
2865ca801bSBALATON Zoltan #include "qemu-common.h"
297709dbf1SBALATON Zoltan #include "qemu/log.h"
3065ca801bSBALATON Zoltan #include "cpu.h"
3165ca801bSBALATON Zoltan #include "hw/hw.h"
323b09bb0fSBALATON Zoltan #include "hw/i2c/ppc4xx_i2c.h"
3365ca801bSBALATON Zoltan 
3442a907e8SBALATON Zoltan #define PPC4xx_I2C_MEM_SIZE 18
3565ca801bSBALATON Zoltan 
367709dbf1SBALATON Zoltan #define IIC_CNTL_PT         (1 << 0)
377709dbf1SBALATON Zoltan #define IIC_CNTL_READ       (1 << 1)
387709dbf1SBALATON Zoltan #define IIC_CNTL_CHT        (1 << 2)
397709dbf1SBALATON Zoltan #define IIC_CNTL_RPST       (1 << 3)
407709dbf1SBALATON Zoltan 
417709dbf1SBALATON Zoltan #define IIC_STS_PT          (1 << 0)
427709dbf1SBALATON Zoltan #define IIC_STS_ERR         (1 << 2)
437709dbf1SBALATON Zoltan #define IIC_STS_MDBS        (1 << 5)
447709dbf1SBALATON Zoltan 
457709dbf1SBALATON Zoltan #define IIC_EXTSTS_XFRA     (1 << 0)
467709dbf1SBALATON Zoltan 
477709dbf1SBALATON Zoltan #define IIC_XTCNTLSS_SRST   (1 << 0)
487709dbf1SBALATON Zoltan 
497709dbf1SBALATON Zoltan static void ppc4xx_i2c_reset(DeviceState *s)
507709dbf1SBALATON Zoltan {
517709dbf1SBALATON Zoltan     PPC4xxI2CState *i2c = PPC4xx_I2C(s);
527709dbf1SBALATON Zoltan 
537709dbf1SBALATON Zoltan     /* FIXME: Should also reset bus?
547709dbf1SBALATON Zoltan      *if (s->address != ADDR_RESET) {
557709dbf1SBALATON Zoltan      *    i2c_end_transfer(s->bus);
567709dbf1SBALATON Zoltan      *}
577709dbf1SBALATON Zoltan      */
587709dbf1SBALATON Zoltan 
597709dbf1SBALATON Zoltan     i2c->mdata = 0;
607709dbf1SBALATON Zoltan     i2c->lmadr = 0;
617709dbf1SBALATON Zoltan     i2c->hmadr = 0;
627709dbf1SBALATON Zoltan     i2c->cntl = 0;
637709dbf1SBALATON Zoltan     i2c->mdcntl = 0;
647709dbf1SBALATON Zoltan     i2c->sts = 0;
657709dbf1SBALATON Zoltan     i2c->extsts = 0x8f;
667709dbf1SBALATON Zoltan     i2c->lsadr = 0;
677709dbf1SBALATON Zoltan     i2c->hsadr = 0;
687709dbf1SBALATON Zoltan     i2c->clkdiv = 0;
697709dbf1SBALATON Zoltan     i2c->intrmsk = 0;
707709dbf1SBALATON Zoltan     i2c->xfrcnt = 0;
717709dbf1SBALATON Zoltan     i2c->xtcntlss = 0;
7242a907e8SBALATON Zoltan     i2c->directcntl = 0xf;
737709dbf1SBALATON Zoltan }
747709dbf1SBALATON Zoltan 
757709dbf1SBALATON Zoltan static inline bool ppc4xx_i2c_is_master(PPC4xxI2CState *i2c)
767709dbf1SBALATON Zoltan {
777709dbf1SBALATON Zoltan     return true;
787709dbf1SBALATON Zoltan }
7965ca801bSBALATON Zoltan 
803b09bb0fSBALATON Zoltan static uint64_t ppc4xx_i2c_readb(void *opaque, hwaddr addr, unsigned int size)
8165ca801bSBALATON Zoltan {
823b09bb0fSBALATON Zoltan     PPC4xxI2CState *i2c = PPC4xx_I2C(opaque);
833b09bb0fSBALATON Zoltan     uint64_t ret;
8465ca801bSBALATON Zoltan 
8565ca801bSBALATON Zoltan     switch (addr) {
8642a907e8SBALATON Zoltan     case 0:
8765ca801bSBALATON Zoltan         ret = i2c->mdata;
887709dbf1SBALATON Zoltan         if (ppc4xx_i2c_is_master(i2c)) {
897709dbf1SBALATON Zoltan             ret = 0xff;
907709dbf1SBALATON Zoltan 
917709dbf1SBALATON Zoltan             if (!(i2c->sts & IIC_STS_MDBS)) {
927709dbf1SBALATON Zoltan                 qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read "
937709dbf1SBALATON Zoltan                               "without starting transfer\n",
947709dbf1SBALATON Zoltan                               TYPE_PPC4xx_I2C, __func__);
957709dbf1SBALATON Zoltan             } else {
967709dbf1SBALATON Zoltan                 int pending = (i2c->cntl >> 4) & 3;
977709dbf1SBALATON Zoltan 
987709dbf1SBALATON Zoltan                 /* get the next byte */
997709dbf1SBALATON Zoltan                 int byte = i2c_recv(i2c->bus);
1007709dbf1SBALATON Zoltan 
1017709dbf1SBALATON Zoltan                 if (byte < 0) {
1027709dbf1SBALATON Zoltan                     qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: read failed "
1037709dbf1SBALATON Zoltan                                   "for device 0x%02x\n", TYPE_PPC4xx_I2C,
1047709dbf1SBALATON Zoltan                                   __func__, i2c->lmadr);
1057709dbf1SBALATON Zoltan                     ret = 0xff;
1067709dbf1SBALATON Zoltan                 } else {
1077709dbf1SBALATON Zoltan                     ret = byte;
1087709dbf1SBALATON Zoltan                     /* Raise interrupt if enabled */
1097709dbf1SBALATON Zoltan                     /*ppc4xx_i2c_raise_interrupt(i2c)*/;
1107709dbf1SBALATON Zoltan                 }
1117709dbf1SBALATON Zoltan 
1127709dbf1SBALATON Zoltan                 if (!pending) {
1137709dbf1SBALATON Zoltan                     i2c->sts &= ~IIC_STS_MDBS;
1147709dbf1SBALATON Zoltan                     /*i2c_end_transfer(i2c->bus);*/
1157709dbf1SBALATON Zoltan                 /*} else if (i2c->cntl & (IIC_CNTL_RPST | IIC_CNTL_CHT)) {*/
1167709dbf1SBALATON Zoltan                 } else if (pending) {
1177709dbf1SBALATON Zoltan                     /* current smbus implementation doesn't like
1187709dbf1SBALATON Zoltan                        multibyte xfer repeated start */
1197709dbf1SBALATON Zoltan                     i2c_end_transfer(i2c->bus);
1207709dbf1SBALATON Zoltan                     if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, 1)) {
1217709dbf1SBALATON Zoltan                         /* if non zero is returned, the adress is not valid */
1227709dbf1SBALATON Zoltan                         i2c->sts &= ~IIC_STS_PT;
1237709dbf1SBALATON Zoltan                         i2c->sts |= IIC_STS_ERR;
1247709dbf1SBALATON Zoltan                         i2c->extsts |= IIC_EXTSTS_XFRA;
1257709dbf1SBALATON Zoltan                     } else {
1267709dbf1SBALATON Zoltan                         /*i2c->sts |= IIC_STS_PT;*/
1277709dbf1SBALATON Zoltan                         i2c->sts |= IIC_STS_MDBS;
1287709dbf1SBALATON Zoltan                         i2c->sts &= ~IIC_STS_ERR;
1297709dbf1SBALATON Zoltan                         i2c->extsts = 0;
1307709dbf1SBALATON Zoltan                     }
1317709dbf1SBALATON Zoltan                 }
1327709dbf1SBALATON Zoltan                 pending--;
1337709dbf1SBALATON Zoltan                 i2c->cntl = (i2c->cntl & 0xcf) | (pending << 4);
1347709dbf1SBALATON Zoltan             }
1357709dbf1SBALATON Zoltan         } else {
1367709dbf1SBALATON Zoltan             qemu_log_mask(LOG_UNIMP, "[%s]%s: slave mode not implemented\n",
1377709dbf1SBALATON Zoltan                           TYPE_PPC4xx_I2C, __func__);
1387709dbf1SBALATON Zoltan         }
13965ca801bSBALATON Zoltan         break;
14042a907e8SBALATON Zoltan     case 4:
14165ca801bSBALATON Zoltan         ret = i2c->lmadr;
14265ca801bSBALATON Zoltan         break;
14342a907e8SBALATON Zoltan     case 5:
14465ca801bSBALATON Zoltan         ret = i2c->hmadr;
14565ca801bSBALATON Zoltan         break;
14642a907e8SBALATON Zoltan     case 6:
14765ca801bSBALATON Zoltan         ret = i2c->cntl;
14865ca801bSBALATON Zoltan         break;
14942a907e8SBALATON Zoltan     case 7:
15065ca801bSBALATON Zoltan         ret = i2c->mdcntl;
15165ca801bSBALATON Zoltan         break;
15242a907e8SBALATON Zoltan     case 8:
15365ca801bSBALATON Zoltan         ret = i2c->sts;
15465ca801bSBALATON Zoltan         break;
15542a907e8SBALATON Zoltan     case 9:
15665ca801bSBALATON Zoltan         ret = i2c->extsts;
15765ca801bSBALATON Zoltan         break;
15842a907e8SBALATON Zoltan     case 10:
15965ca801bSBALATON Zoltan         ret = i2c->lsadr;
16065ca801bSBALATON Zoltan         break;
16142a907e8SBALATON Zoltan     case 11:
16265ca801bSBALATON Zoltan         ret = i2c->hsadr;
16365ca801bSBALATON Zoltan         break;
16442a907e8SBALATON Zoltan     case 12:
16565ca801bSBALATON Zoltan         ret = i2c->clkdiv;
16665ca801bSBALATON Zoltan         break;
16742a907e8SBALATON Zoltan     case 13:
16865ca801bSBALATON Zoltan         ret = i2c->intrmsk;
16965ca801bSBALATON Zoltan         break;
17042a907e8SBALATON Zoltan     case 14:
17165ca801bSBALATON Zoltan         ret = i2c->xfrcnt;
17265ca801bSBALATON Zoltan         break;
17342a907e8SBALATON Zoltan     case 15:
17465ca801bSBALATON Zoltan         ret = i2c->xtcntlss;
17565ca801bSBALATON Zoltan         break;
17642a907e8SBALATON Zoltan     case 16:
17765ca801bSBALATON Zoltan         ret = i2c->directcntl;
17865ca801bSBALATON Zoltan         break;
17965ca801bSBALATON Zoltan     default:
18042a907e8SBALATON Zoltan         if (addr < PPC4xx_I2C_MEM_SIZE) {
18142a907e8SBALATON Zoltan             qemu_log_mask(LOG_UNIMP, "%s: Unimplemented register 0x%"
18242a907e8SBALATON Zoltan                           HWADDR_PRIx "\n", __func__, addr);
18342a907e8SBALATON Zoltan         } else {
18442a907e8SBALATON Zoltan             qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address 0x%"
18542a907e8SBALATON Zoltan                           HWADDR_PRIx "\n", __func__, addr);
18642a907e8SBALATON Zoltan         }
1877709dbf1SBALATON Zoltan         ret = 0;
18865ca801bSBALATON Zoltan         break;
18965ca801bSBALATON Zoltan     }
19065ca801bSBALATON Zoltan     return ret;
19165ca801bSBALATON Zoltan }
19265ca801bSBALATON Zoltan 
1933b09bb0fSBALATON Zoltan static void ppc4xx_i2c_writeb(void *opaque, hwaddr addr, uint64_t value,
1943b09bb0fSBALATON Zoltan                               unsigned int size)
19565ca801bSBALATON Zoltan {
1963b09bb0fSBALATON Zoltan     PPC4xxI2CState *i2c = opaque;
1977709dbf1SBALATON Zoltan 
19865ca801bSBALATON Zoltan     switch (addr) {
19942a907e8SBALATON Zoltan     case 0:
20065ca801bSBALATON Zoltan         i2c->mdata = value;
2017709dbf1SBALATON Zoltan         if (!i2c_bus_busy(i2c->bus)) {
2027709dbf1SBALATON Zoltan             /* assume we start a write transfer */
2037709dbf1SBALATON Zoltan             if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, 0)) {
2047709dbf1SBALATON Zoltan                 /* if non zero is returned, the adress is not valid */
2057709dbf1SBALATON Zoltan                 i2c->sts &= ~IIC_STS_PT;
2067709dbf1SBALATON Zoltan                 i2c->sts |= IIC_STS_ERR;
2077709dbf1SBALATON Zoltan                 i2c->extsts |= IIC_EXTSTS_XFRA;
2087709dbf1SBALATON Zoltan             } else {
2097709dbf1SBALATON Zoltan                 i2c->sts |= IIC_STS_PT;
2107709dbf1SBALATON Zoltan                 i2c->sts &= ~IIC_STS_ERR;
2117709dbf1SBALATON Zoltan                 i2c->extsts = 0;
2127709dbf1SBALATON Zoltan             }
2137709dbf1SBALATON Zoltan         }
2147709dbf1SBALATON Zoltan         if (i2c_bus_busy(i2c->bus)) {
2157709dbf1SBALATON Zoltan             if (i2c_send(i2c->bus, i2c->mdata)) {
2167709dbf1SBALATON Zoltan                 /* if the target return non zero then end the transfer */
2177709dbf1SBALATON Zoltan                 i2c->sts &= ~IIC_STS_PT;
2187709dbf1SBALATON Zoltan                 i2c->sts |= IIC_STS_ERR;
2197709dbf1SBALATON Zoltan                 i2c->extsts |= IIC_EXTSTS_XFRA;
2207709dbf1SBALATON Zoltan                 i2c_end_transfer(i2c->bus);
2217709dbf1SBALATON Zoltan             }
2227709dbf1SBALATON Zoltan         }
22365ca801bSBALATON Zoltan         break;
22442a907e8SBALATON Zoltan     case 4:
22565ca801bSBALATON Zoltan         i2c->lmadr = value;
2267709dbf1SBALATON Zoltan         if (i2c_bus_busy(i2c->bus)) {
2277709dbf1SBALATON Zoltan             i2c_end_transfer(i2c->bus);
2287709dbf1SBALATON Zoltan         }
22965ca801bSBALATON Zoltan         break;
23042a907e8SBALATON Zoltan     case 5:
23165ca801bSBALATON Zoltan         i2c->hmadr = value;
23265ca801bSBALATON Zoltan         break;
23342a907e8SBALATON Zoltan     case 6:
23465ca801bSBALATON Zoltan         i2c->cntl = value;
2357709dbf1SBALATON Zoltan         if (i2c->cntl & IIC_CNTL_PT) {
2367709dbf1SBALATON Zoltan             if (i2c->cntl & IIC_CNTL_READ) {
2377709dbf1SBALATON Zoltan                 if (i2c_bus_busy(i2c->bus)) {
2387709dbf1SBALATON Zoltan                     /* end previous transfer */
2397709dbf1SBALATON Zoltan                     i2c->sts &= ~IIC_STS_PT;
2407709dbf1SBALATON Zoltan                     i2c_end_transfer(i2c->bus);
2417709dbf1SBALATON Zoltan                 }
2427709dbf1SBALATON Zoltan                 if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, 1)) {
2437709dbf1SBALATON Zoltan                     /* if non zero is returned, the adress is not valid */
2447709dbf1SBALATON Zoltan                     i2c->sts &= ~IIC_STS_PT;
2457709dbf1SBALATON Zoltan                     i2c->sts |= IIC_STS_ERR;
2467709dbf1SBALATON Zoltan                     i2c->extsts |= IIC_EXTSTS_XFRA;
2477709dbf1SBALATON Zoltan                 } else {
2487709dbf1SBALATON Zoltan                     /*i2c->sts |= IIC_STS_PT;*/
2497709dbf1SBALATON Zoltan                     i2c->sts |= IIC_STS_MDBS;
2507709dbf1SBALATON Zoltan                     i2c->sts &= ~IIC_STS_ERR;
2517709dbf1SBALATON Zoltan                     i2c->extsts = 0;
2527709dbf1SBALATON Zoltan                 }
2537709dbf1SBALATON Zoltan             } else {
2547709dbf1SBALATON Zoltan                 /* we actually already did the write transfer... */
2557709dbf1SBALATON Zoltan                 i2c->sts &= ~IIC_STS_PT;
2567709dbf1SBALATON Zoltan             }
2577709dbf1SBALATON Zoltan         }
25865ca801bSBALATON Zoltan         break;
25942a907e8SBALATON Zoltan     case 7:
26042a907e8SBALATON Zoltan         i2c->mdcntl = value & 0xdf;
26165ca801bSBALATON Zoltan         break;
26242a907e8SBALATON Zoltan     case 8:
26342a907e8SBALATON Zoltan         i2c->sts &= ~(value & 0xa);
26465ca801bSBALATON Zoltan         break;
26542a907e8SBALATON Zoltan     case 9:
26642a907e8SBALATON Zoltan         i2c->extsts &= ~(value & 0x8f);
26765ca801bSBALATON Zoltan         break;
26842a907e8SBALATON Zoltan     case 10:
26965ca801bSBALATON Zoltan         i2c->lsadr = value;
27065ca801bSBALATON Zoltan         break;
27142a907e8SBALATON Zoltan     case 11:
27265ca801bSBALATON Zoltan         i2c->hsadr = value;
27365ca801bSBALATON Zoltan         break;
27442a907e8SBALATON Zoltan     case 12:
27565ca801bSBALATON Zoltan         i2c->clkdiv = value;
27665ca801bSBALATON Zoltan         break;
27742a907e8SBALATON Zoltan     case 13:
27865ca801bSBALATON Zoltan         i2c->intrmsk = value;
27965ca801bSBALATON Zoltan         break;
28042a907e8SBALATON Zoltan     case 14:
28165ca801bSBALATON Zoltan         i2c->xfrcnt = value & 0x77;
28265ca801bSBALATON Zoltan         break;
28342a907e8SBALATON Zoltan     case 15:
2847709dbf1SBALATON Zoltan         if (value & IIC_XTCNTLSS_SRST) {
2857709dbf1SBALATON Zoltan             /* Is it actually a full reset? U-Boot sets some regs before */
2867709dbf1SBALATON Zoltan             ppc4xx_i2c_reset(DEVICE(i2c));
2877709dbf1SBALATON Zoltan             break;
2887709dbf1SBALATON Zoltan         }
28965ca801bSBALATON Zoltan         i2c->xtcntlss = value;
29065ca801bSBALATON Zoltan         break;
29142a907e8SBALATON Zoltan     case 16:
29265ca801bSBALATON Zoltan         i2c->directcntl = value & 0x7;
29365ca801bSBALATON Zoltan         break;
2947709dbf1SBALATON Zoltan     default:
29542a907e8SBALATON Zoltan         if (addr < PPC4xx_I2C_MEM_SIZE) {
29642a907e8SBALATON Zoltan             qemu_log_mask(LOG_UNIMP, "%s: Unimplemented register 0x%"
29742a907e8SBALATON Zoltan                           HWADDR_PRIx "\n", __func__, addr);
29842a907e8SBALATON Zoltan         } else {
29942a907e8SBALATON Zoltan             qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address 0x%"
30042a907e8SBALATON Zoltan                           HWADDR_PRIx "\n", __func__, addr);
30142a907e8SBALATON Zoltan         }
3027709dbf1SBALATON Zoltan         break;
30365ca801bSBALATON Zoltan     }
30465ca801bSBALATON Zoltan }
30565ca801bSBALATON Zoltan 
3063b09bb0fSBALATON Zoltan static const MemoryRegionOps ppc4xx_i2c_ops = {
3073b09bb0fSBALATON Zoltan     .read = ppc4xx_i2c_readb,
3083b09bb0fSBALATON Zoltan     .write = ppc4xx_i2c_writeb,
3093b09bb0fSBALATON Zoltan     .valid.min_access_size = 1,
3103b09bb0fSBALATON Zoltan     .valid.max_access_size = 4,
3113b09bb0fSBALATON Zoltan     .impl.min_access_size = 1,
3123b09bb0fSBALATON Zoltan     .impl.max_access_size = 1,
31365ca801bSBALATON Zoltan     .endianness = DEVICE_NATIVE_ENDIAN,
31465ca801bSBALATON Zoltan };
31565ca801bSBALATON Zoltan 
3163b09bb0fSBALATON Zoltan static void ppc4xx_i2c_init(Object *o)
31765ca801bSBALATON Zoltan {
3183b09bb0fSBALATON Zoltan     PPC4xxI2CState *s = PPC4xx_I2C(o);
31965ca801bSBALATON Zoltan 
3203b09bb0fSBALATON Zoltan     memory_region_init_io(&s->iomem, OBJECT(s), &ppc4xx_i2c_ops, s,
3213b09bb0fSBALATON Zoltan                           TYPE_PPC4xx_I2C, PPC4xx_I2C_MEM_SIZE);
3223b09bb0fSBALATON Zoltan     sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
3233b09bb0fSBALATON Zoltan     sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq);
3243b09bb0fSBALATON Zoltan     s->bus = i2c_init_bus(DEVICE(s), "i2c");
32565ca801bSBALATON Zoltan }
3263b09bb0fSBALATON Zoltan 
3273b09bb0fSBALATON Zoltan static void ppc4xx_i2c_class_init(ObjectClass *klass, void *data)
3283b09bb0fSBALATON Zoltan {
3293b09bb0fSBALATON Zoltan     DeviceClass *dc = DEVICE_CLASS(klass);
3303b09bb0fSBALATON Zoltan 
3313b09bb0fSBALATON Zoltan     dc->reset = ppc4xx_i2c_reset;
3323b09bb0fSBALATON Zoltan }
3333b09bb0fSBALATON Zoltan 
3343b09bb0fSBALATON Zoltan static const TypeInfo ppc4xx_i2c_type_info = {
3353b09bb0fSBALATON Zoltan     .name = TYPE_PPC4xx_I2C,
3363b09bb0fSBALATON Zoltan     .parent = TYPE_SYS_BUS_DEVICE,
3373b09bb0fSBALATON Zoltan     .instance_size = sizeof(PPC4xxI2CState),
3383b09bb0fSBALATON Zoltan     .instance_init = ppc4xx_i2c_init,
3393b09bb0fSBALATON Zoltan     .class_init = ppc4xx_i2c_class_init,
3403b09bb0fSBALATON Zoltan };
3413b09bb0fSBALATON Zoltan 
3423b09bb0fSBALATON Zoltan static void ppc4xx_i2c_register_types(void)
3433b09bb0fSBALATON Zoltan {
3443b09bb0fSBALATON Zoltan     type_register_static(&ppc4xx_i2c_type_info);
3453b09bb0fSBALATON Zoltan }
3463b09bb0fSBALATON Zoltan 
3473b09bb0fSBALATON Zoltan type_init(ppc4xx_i2c_register_types)
348