Loading drivers/gpu/drm/nouveau/dispnv04/dfp.c +5 −6 Original line number Diff line number Diff line Loading @@ -624,8 +624,8 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder) struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); struct nvkm_i2c_port *port = i2c->find(i2c, 2); struct nvkm_i2c_board_info info[] = { struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI); struct nvkm_i2c_bus_probe info[] = { { { .type = "sil164", Loading @@ -639,16 +639,15 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder) }; int type; if (!nv_gf4_disp_arch(dev) || !port || get_tmds_slave(encoder)) if (!nv_gf4_disp_arch(dev) || !bus || get_tmds_slave(encoder)) return; type = i2c->identify(i2c, 2, "TMDS transmitter", info, NULL, NULL); type = nvkm_i2c_bus_probe(bus, "TMDS transmitter", info, NULL, NULL); if (type < 0) return; drm_i2c_encoder_init(dev, to_encoder_slave(encoder), &port->adapter, &info[type].dev); &bus->i2c, &info[type].dev); } static const struct drm_encoder_helper_funcs nv04_lvds_helper_funcs = { Loading drivers/gpu/drm/nouveau/dispnv04/disp.c +3 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,9 @@ nv04_display_create(struct drm_device *dev) list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); nv_encoder->i2c = i2c->find(i2c, nv_encoder->dcb->i2c_index); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, nv_encoder->dcb->i2c_index); nv_encoder->i2c = bus ? &bus->i2c : NULL; } /* Save previous state */ Loading drivers/gpu/drm/nouveau/dispnv04/tvnv04.c +10 −6 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ #include <drm/i2c/ch7006.h> static struct nvkm_i2c_board_info nv04_tv_encoder_info[] = { static struct nvkm_i2c_bus_probe nv04_tv_encoder_info[] = { { { I2C_BOARD_INFO("ch7006", 0x75), Loading @@ -55,9 +55,13 @@ int nv04_tv_identify(struct drm_device *dev, int i2c_index) { struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); return i2c->identify(i2c, i2c_index, "TV encoder", nv04_tv_encoder_info, NULL, NULL); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, i2c_index); if (bus) { return nvkm_i2c_bus_probe(bus, "TV encoder", nv04_tv_encoder_info, NULL, NULL); } return -ENODEV; } Loading Loading @@ -205,7 +209,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry) struct drm_device *dev = connector->dev; struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); struct nvkm_i2c_port *port = i2c->find(i2c, entry->i2c_index); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, entry->i2c_index); int type, ret; /* Ensure that we can talk to this encoder */ Loading @@ -231,7 +235,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry) /* Run the slave-specific initialization */ ret = drm_i2c_encoder_init(dev, to_encoder_slave(encoder), &port->adapter, &bus->i2c, &nv04_tv_encoder_info[type].dev); if (ret < 0) goto fail_cleanup; Loading drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h +73 −52 Original line number Diff line number Diff line Loading @@ -6,15 +6,6 @@ #include <subdev/bios.h> #include <subdev/bios/i2c.h> #define NV_I2C_PORT(n) (0x00 + (n)) #define NV_I2C_AUX(n) (0x10 + (n)) #define NV_I2C_EXT(n) (0x20 + (n)) #define NV_I2C_DEFAULT(n) (0x80 + (n)) #define NV_I2C_TYPE_DCBI2C(n) (0x0000 | (n)) #define NV_I2C_TYPE_EXTDDC(e) (0x0005 | (e) << 8) #define NV_I2C_TYPE_EXTAUX(e) (0x0006 | (e) << 8) struct nvkm_i2c_ntfy_req { #define NVKM_I2C_PLUG 0x01 #define NVKM_I2C_UNPLUG 0x02 Loading @@ -29,55 +20,66 @@ struct nvkm_i2c_ntfy_rep { u8 mask; }; struct nvkm_i2c_port { struct nvkm_object base; struct i2c_adapter adapter; struct mutex mutex; struct nvkm_i2c_bus_probe { struct i2c_board_info dev; u8 udelay; /* set to 0 to use the standard delay */ }; struct list_head head; u8 index; int aux; struct nvkm_i2c_bus { const struct nvkm_i2c_bus_func *func; struct nvkm_i2c_pad *pad; #define NVKM_I2C_BUS_CCB(n) /* 'n' is ccb index */ (n) #define NVKM_I2C_BUS_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x100) #define NVKM_I2C_BUS_PRI /* ccb primary comm. port */ -1 #define NVKM_I2C_BUS_SEC /* ccb secondary comm. port */ -2 int id; const struct nvkm_i2c_func *func; struct mutex mutex; struct list_head head; struct i2c_adapter i2c; }; struct nvkm_i2c_func { void (*drive_scl)(struct nvkm_i2c_port *, int); void (*drive_sda)(struct nvkm_i2c_port *, int); int (*sense_scl)(struct nvkm_i2c_port *); int (*sense_sda)(struct nvkm_i2c_port *); int nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *); void nvkm_i2c_bus_release(struct nvkm_i2c_bus *); int nvkm_i2c_bus_probe(struct nvkm_i2c_bus *, const char *, struct nvkm_i2c_bus_probe *, bool (*)(struct nvkm_i2c_bus *, struct i2c_board_info *, void *), void *); int (*aux)(struct nvkm_i2c_port *, bool, u8, u32, u8 *, u8); int (*pattern)(struct nvkm_i2c_port *, int pattern); int (*lnk_ctl)(struct nvkm_i2c_port *, int nr, int bw, bool enh); int (*drv_ctl)(struct nvkm_i2c_port *, int lane, int sw, int pe); }; struct nvkm_i2c_aux { const struct nvkm_i2c_aux_func *func; struct nvkm_i2c_pad *pad; #define NVKM_I2C_AUX_CCB(n) /* 'n' is ccb index */ (n) #define NVKM_I2C_AUX_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x100) int id; struct nvkm_i2c_board_info { struct i2c_board_info dev; u8 udelay; /* set to 0 to use the standard delay */ struct mutex mutex; struct list_head head; struct i2c_adapter i2c; u32 intr; }; void nvkm_i2c_aux_monitor(struct nvkm_i2c_aux *, bool monitor); int nvkm_i2c_aux_acquire(struct nvkm_i2c_aux *); void nvkm_i2c_aux_release(struct nvkm_i2c_aux *); int nvkm_i2c_aux_xfer(struct nvkm_i2c_aux *, bool retry, u8 type, u32 addr, u8 *data, u8 size); int nvkm_i2c_aux_lnk_ctl(struct nvkm_i2c_aux *, int link_nr, int link_bw, bool enhanced_framing); struct nvkm_i2c { struct nvkm_subdev subdev; struct nvkm_event event; struct nvkm_i2c_port *(*find)(struct nvkm_i2c *, u8 index); struct nvkm_i2c_port *(*find_type)(struct nvkm_i2c *, u16 type); int (*acquire_pad)(struct nvkm_i2c_port *, unsigned long timeout); void (*release_pad)(struct nvkm_i2c_port *); int (*acquire)(struct nvkm_i2c_port *, unsigned long timeout); void (*release)(struct nvkm_i2c_port *); int (*identify)(struct nvkm_i2c *, int index, const char *what, struct nvkm_i2c_board_info *, bool (*match)(struct nvkm_i2c_port *, struct i2c_board_info *, void *), void *); wait_queue_head_t wait; struct list_head ports; struct list_head pad; struct list_head bus; struct list_head aux; }; struct nvkm_i2c_bus *nvkm_i2c_bus_find(struct nvkm_i2c *, int); struct nvkm_i2c_aux *nvkm_i2c_aux_find(struct nvkm_i2c *, int); static inline struct nvkm_i2c * nvkm_i2c(void *obj) { Loading @@ -94,7 +96,7 @@ extern struct nvkm_oclass *gk104_i2c_oclass; extern struct nvkm_oclass *gm204_i2c_oclass; static inline int nv_rdi2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg) nvkm_rdi2cr(struct i2c_adapter *adap, u8 addr, u8 reg) { u8 val; struct i2c_msg msgs[] = { Loading @@ -102,7 +104,7 @@ nv_rdi2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg) { .addr = addr, .flags = I2C_M_RD, .len = 1, .buf = &val }, }; int ret = i2c_transfer(&port->adapter, msgs, 2); int ret = i2c_transfer(adap, msgs, ARRAY_SIZE(msgs)); if (ret != 2) return -EIO; Loading @@ -110,14 +112,14 @@ nv_rdi2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg) } static inline int nv_wri2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg, u8 val) nvkm_wri2cr(struct i2c_adapter *adap, u8 addr, u8 reg, u8 val) { u8 buf[2] = { reg, val }; struct i2c_msg msgs[] = { { .addr = addr, .flags = 0, .len = 2, .buf = buf }, }; int ret = i2c_transfer(&port->adapter, msgs, 1); int ret = i2c_transfer(adap, msgs, ARRAY_SIZE(msgs)); if (ret != 1) return -EIO; Loading @@ -125,11 +127,30 @@ nv_wri2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg, u8 val) } static inline bool nv_probe_i2c(struct nvkm_i2c_port *port, u8 addr) nvkm_probe_i2c(struct i2c_adapter *adap, u8 addr) { return nv_rdi2cr(port, addr, 0) >= 0; return nvkm_rdi2cr(adap, addr, 0) >= 0; } int nv_rdaux(struct nvkm_i2c_port *, u32 addr, u8 *data, u8 size); int nv_wraux(struct nvkm_i2c_port *, u32 addr, u8 *data, u8 size); static inline int nvkm_rdaux(struct nvkm_i2c_aux *aux, u32 addr, u8 *data, u8 size) { int ret = nvkm_i2c_aux_acquire(aux); if (ret == 0) { ret = nvkm_i2c_aux_xfer(aux, true, 9, addr, data, size); nvkm_i2c_aux_release(aux); } return ret; } static inline int nvkm_wraux(struct nvkm_i2c_aux *aux, u32 addr, u8 *data, u8 size) { int ret = nvkm_i2c_aux_acquire(aux); if (ret == 0) { ret = nvkm_i2c_aux_xfer(aux, true, 8, addr, data, size); nvkm_i2c_aux_release(aux); } return ret; } #endif drivers/gpu/drm/nouveau/nouveau_bios.c +0 −1 Original line number Diff line number Diff line Loading @@ -1495,7 +1495,6 @@ parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb, break; } link = entry->dpconf.sor.link; entry->i2c_index += NV_I2C_AUX(0); break; case DCB_OUTPUT_TMDS: if (dcb->version >= 0x40) { Loading Loading
drivers/gpu/drm/nouveau/dispnv04/dfp.c +5 −6 Original line number Diff line number Diff line Loading @@ -624,8 +624,8 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder) struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); struct nvkm_i2c_port *port = i2c->find(i2c, 2); struct nvkm_i2c_board_info info[] = { struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI); struct nvkm_i2c_bus_probe info[] = { { { .type = "sil164", Loading @@ -639,16 +639,15 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder) }; int type; if (!nv_gf4_disp_arch(dev) || !port || get_tmds_slave(encoder)) if (!nv_gf4_disp_arch(dev) || !bus || get_tmds_slave(encoder)) return; type = i2c->identify(i2c, 2, "TMDS transmitter", info, NULL, NULL); type = nvkm_i2c_bus_probe(bus, "TMDS transmitter", info, NULL, NULL); if (type < 0) return; drm_i2c_encoder_init(dev, to_encoder_slave(encoder), &port->adapter, &info[type].dev); &bus->i2c, &info[type].dev); } static const struct drm_encoder_helper_funcs nv04_lvds_helper_funcs = { Loading
drivers/gpu/drm/nouveau/dispnv04/disp.c +3 −1 Original line number Diff line number Diff line Loading @@ -101,7 +101,9 @@ nv04_display_create(struct drm_device *dev) list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); nv_encoder->i2c = i2c->find(i2c, nv_encoder->dcb->i2c_index); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, nv_encoder->dcb->i2c_index); nv_encoder->i2c = bus ? &bus->i2c : NULL; } /* Save previous state */ Loading
drivers/gpu/drm/nouveau/dispnv04/tvnv04.c +10 −6 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ #include <drm/i2c/ch7006.h> static struct nvkm_i2c_board_info nv04_tv_encoder_info[] = { static struct nvkm_i2c_bus_probe nv04_tv_encoder_info[] = { { { I2C_BOARD_INFO("ch7006", 0x75), Loading @@ -55,9 +55,13 @@ int nv04_tv_identify(struct drm_device *dev, int i2c_index) { struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); return i2c->identify(i2c, i2c_index, "TV encoder", nv04_tv_encoder_info, NULL, NULL); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, i2c_index); if (bus) { return nvkm_i2c_bus_probe(bus, "TV encoder", nv04_tv_encoder_info, NULL, NULL); } return -ENODEV; } Loading Loading @@ -205,7 +209,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry) struct drm_device *dev = connector->dev; struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); struct nvkm_i2c_port *port = i2c->find(i2c, entry->i2c_index); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, entry->i2c_index); int type, ret; /* Ensure that we can talk to this encoder */ Loading @@ -231,7 +235,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry) /* Run the slave-specific initialization */ ret = drm_i2c_encoder_init(dev, to_encoder_slave(encoder), &port->adapter, &bus->i2c, &nv04_tv_encoder_info[type].dev); if (ret < 0) goto fail_cleanup; Loading
drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h +73 −52 Original line number Diff line number Diff line Loading @@ -6,15 +6,6 @@ #include <subdev/bios.h> #include <subdev/bios/i2c.h> #define NV_I2C_PORT(n) (0x00 + (n)) #define NV_I2C_AUX(n) (0x10 + (n)) #define NV_I2C_EXT(n) (0x20 + (n)) #define NV_I2C_DEFAULT(n) (0x80 + (n)) #define NV_I2C_TYPE_DCBI2C(n) (0x0000 | (n)) #define NV_I2C_TYPE_EXTDDC(e) (0x0005 | (e) << 8) #define NV_I2C_TYPE_EXTAUX(e) (0x0006 | (e) << 8) struct nvkm_i2c_ntfy_req { #define NVKM_I2C_PLUG 0x01 #define NVKM_I2C_UNPLUG 0x02 Loading @@ -29,55 +20,66 @@ struct nvkm_i2c_ntfy_rep { u8 mask; }; struct nvkm_i2c_port { struct nvkm_object base; struct i2c_adapter adapter; struct mutex mutex; struct nvkm_i2c_bus_probe { struct i2c_board_info dev; u8 udelay; /* set to 0 to use the standard delay */ }; struct list_head head; u8 index; int aux; struct nvkm_i2c_bus { const struct nvkm_i2c_bus_func *func; struct nvkm_i2c_pad *pad; #define NVKM_I2C_BUS_CCB(n) /* 'n' is ccb index */ (n) #define NVKM_I2C_BUS_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x100) #define NVKM_I2C_BUS_PRI /* ccb primary comm. port */ -1 #define NVKM_I2C_BUS_SEC /* ccb secondary comm. port */ -2 int id; const struct nvkm_i2c_func *func; struct mutex mutex; struct list_head head; struct i2c_adapter i2c; }; struct nvkm_i2c_func { void (*drive_scl)(struct nvkm_i2c_port *, int); void (*drive_sda)(struct nvkm_i2c_port *, int); int (*sense_scl)(struct nvkm_i2c_port *); int (*sense_sda)(struct nvkm_i2c_port *); int nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *); void nvkm_i2c_bus_release(struct nvkm_i2c_bus *); int nvkm_i2c_bus_probe(struct nvkm_i2c_bus *, const char *, struct nvkm_i2c_bus_probe *, bool (*)(struct nvkm_i2c_bus *, struct i2c_board_info *, void *), void *); int (*aux)(struct nvkm_i2c_port *, bool, u8, u32, u8 *, u8); int (*pattern)(struct nvkm_i2c_port *, int pattern); int (*lnk_ctl)(struct nvkm_i2c_port *, int nr, int bw, bool enh); int (*drv_ctl)(struct nvkm_i2c_port *, int lane, int sw, int pe); }; struct nvkm_i2c_aux { const struct nvkm_i2c_aux_func *func; struct nvkm_i2c_pad *pad; #define NVKM_I2C_AUX_CCB(n) /* 'n' is ccb index */ (n) #define NVKM_I2C_AUX_EXT(n) /* 'n' is dcb external encoder type */ ((n) + 0x100) int id; struct nvkm_i2c_board_info { struct i2c_board_info dev; u8 udelay; /* set to 0 to use the standard delay */ struct mutex mutex; struct list_head head; struct i2c_adapter i2c; u32 intr; }; void nvkm_i2c_aux_monitor(struct nvkm_i2c_aux *, bool monitor); int nvkm_i2c_aux_acquire(struct nvkm_i2c_aux *); void nvkm_i2c_aux_release(struct nvkm_i2c_aux *); int nvkm_i2c_aux_xfer(struct nvkm_i2c_aux *, bool retry, u8 type, u32 addr, u8 *data, u8 size); int nvkm_i2c_aux_lnk_ctl(struct nvkm_i2c_aux *, int link_nr, int link_bw, bool enhanced_framing); struct nvkm_i2c { struct nvkm_subdev subdev; struct nvkm_event event; struct nvkm_i2c_port *(*find)(struct nvkm_i2c *, u8 index); struct nvkm_i2c_port *(*find_type)(struct nvkm_i2c *, u16 type); int (*acquire_pad)(struct nvkm_i2c_port *, unsigned long timeout); void (*release_pad)(struct nvkm_i2c_port *); int (*acquire)(struct nvkm_i2c_port *, unsigned long timeout); void (*release)(struct nvkm_i2c_port *); int (*identify)(struct nvkm_i2c *, int index, const char *what, struct nvkm_i2c_board_info *, bool (*match)(struct nvkm_i2c_port *, struct i2c_board_info *, void *), void *); wait_queue_head_t wait; struct list_head ports; struct list_head pad; struct list_head bus; struct list_head aux; }; struct nvkm_i2c_bus *nvkm_i2c_bus_find(struct nvkm_i2c *, int); struct nvkm_i2c_aux *nvkm_i2c_aux_find(struct nvkm_i2c *, int); static inline struct nvkm_i2c * nvkm_i2c(void *obj) { Loading @@ -94,7 +96,7 @@ extern struct nvkm_oclass *gk104_i2c_oclass; extern struct nvkm_oclass *gm204_i2c_oclass; static inline int nv_rdi2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg) nvkm_rdi2cr(struct i2c_adapter *adap, u8 addr, u8 reg) { u8 val; struct i2c_msg msgs[] = { Loading @@ -102,7 +104,7 @@ nv_rdi2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg) { .addr = addr, .flags = I2C_M_RD, .len = 1, .buf = &val }, }; int ret = i2c_transfer(&port->adapter, msgs, 2); int ret = i2c_transfer(adap, msgs, ARRAY_SIZE(msgs)); if (ret != 2) return -EIO; Loading @@ -110,14 +112,14 @@ nv_rdi2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg) } static inline int nv_wri2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg, u8 val) nvkm_wri2cr(struct i2c_adapter *adap, u8 addr, u8 reg, u8 val) { u8 buf[2] = { reg, val }; struct i2c_msg msgs[] = { { .addr = addr, .flags = 0, .len = 2, .buf = buf }, }; int ret = i2c_transfer(&port->adapter, msgs, 1); int ret = i2c_transfer(adap, msgs, ARRAY_SIZE(msgs)); if (ret != 1) return -EIO; Loading @@ -125,11 +127,30 @@ nv_wri2cr(struct nvkm_i2c_port *port, u8 addr, u8 reg, u8 val) } static inline bool nv_probe_i2c(struct nvkm_i2c_port *port, u8 addr) nvkm_probe_i2c(struct i2c_adapter *adap, u8 addr) { return nv_rdi2cr(port, addr, 0) >= 0; return nvkm_rdi2cr(adap, addr, 0) >= 0; } int nv_rdaux(struct nvkm_i2c_port *, u32 addr, u8 *data, u8 size); int nv_wraux(struct nvkm_i2c_port *, u32 addr, u8 *data, u8 size); static inline int nvkm_rdaux(struct nvkm_i2c_aux *aux, u32 addr, u8 *data, u8 size) { int ret = nvkm_i2c_aux_acquire(aux); if (ret == 0) { ret = nvkm_i2c_aux_xfer(aux, true, 9, addr, data, size); nvkm_i2c_aux_release(aux); } return ret; } static inline int nvkm_wraux(struct nvkm_i2c_aux *aux, u32 addr, u8 *data, u8 size) { int ret = nvkm_i2c_aux_acquire(aux); if (ret == 0) { ret = nvkm_i2c_aux_xfer(aux, true, 8, addr, data, size); nvkm_i2c_aux_release(aux); } return ret; } #endif
drivers/gpu/drm/nouveau/nouveau_bios.c +0 −1 Original line number Diff line number Diff line Loading @@ -1495,7 +1495,6 @@ parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb, break; } link = entry->dpconf.sor.link; entry->i2c_index += NV_I2C_AUX(0); break; case DCB_OUTPUT_TMDS: if (dcb->version >= 0x40) { Loading