Lines Matching +full:bit +full:- +full:banging
2 * Copyright 2007-8 Advanced Micro Devices, Inc.
39 /* bit banging i2c */
43 struct amdgpu_device *adev = drm_to_adev(i2c->dev); in amdgpu_i2c_pre_xfer()
44 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; in amdgpu_i2c_pre_xfer()
47 mutex_lock(&i2c->mutex); in amdgpu_i2c_pre_xfer()
50 if (rec->hw_capable) { in amdgpu_i2c_pre_xfer()
51 temp = RREG32(rec->mask_clk_reg); in amdgpu_i2c_pre_xfer()
53 WREG32(rec->mask_clk_reg, temp); in amdgpu_i2c_pre_xfer()
57 temp = RREG32(rec->a_clk_reg) & ~rec->a_clk_mask; in amdgpu_i2c_pre_xfer()
58 WREG32(rec->a_clk_reg, temp); in amdgpu_i2c_pre_xfer()
60 temp = RREG32(rec->a_data_reg) & ~rec->a_data_mask; in amdgpu_i2c_pre_xfer()
61 WREG32(rec->a_data_reg, temp); in amdgpu_i2c_pre_xfer()
64 temp = RREG32(rec->en_clk_reg) & ~rec->en_clk_mask; in amdgpu_i2c_pre_xfer()
65 WREG32(rec->en_clk_reg, temp); in amdgpu_i2c_pre_xfer()
67 temp = RREG32(rec->en_data_reg) & ~rec->en_data_mask; in amdgpu_i2c_pre_xfer()
68 WREG32(rec->en_data_reg, temp); in amdgpu_i2c_pre_xfer()
71 temp = RREG32(rec->mask_clk_reg) | rec->mask_clk_mask; in amdgpu_i2c_pre_xfer()
72 WREG32(rec->mask_clk_reg, temp); in amdgpu_i2c_pre_xfer()
73 temp = RREG32(rec->mask_clk_reg); in amdgpu_i2c_pre_xfer()
75 temp = RREG32(rec->mask_data_reg) | rec->mask_data_mask; in amdgpu_i2c_pre_xfer()
76 WREG32(rec->mask_data_reg, temp); in amdgpu_i2c_pre_xfer()
77 temp = RREG32(rec->mask_data_reg); in amdgpu_i2c_pre_xfer()
85 struct amdgpu_device *adev = drm_to_adev(i2c->dev); in amdgpu_i2c_post_xfer()
86 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; in amdgpu_i2c_post_xfer()
90 temp = RREG32(rec->mask_clk_reg) & ~rec->mask_clk_mask; in amdgpu_i2c_post_xfer()
91 WREG32(rec->mask_clk_reg, temp); in amdgpu_i2c_post_xfer()
92 temp = RREG32(rec->mask_clk_reg); in amdgpu_i2c_post_xfer()
94 temp = RREG32(rec->mask_data_reg) & ~rec->mask_data_mask; in amdgpu_i2c_post_xfer()
95 WREG32(rec->mask_data_reg, temp); in amdgpu_i2c_post_xfer()
96 temp = RREG32(rec->mask_data_reg); in amdgpu_i2c_post_xfer()
98 mutex_unlock(&i2c->mutex); in amdgpu_i2c_post_xfer()
104 struct amdgpu_device *adev = drm_to_adev(i2c->dev); in amdgpu_i2c_get_clock()
105 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; in amdgpu_i2c_get_clock()
109 val = RREG32(rec->y_clk_reg); in amdgpu_i2c_get_clock()
110 val &= rec->y_clk_mask; in amdgpu_i2c_get_clock()
119 struct amdgpu_device *adev = drm_to_adev(i2c->dev); in amdgpu_i2c_get_data()
120 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; in amdgpu_i2c_get_data()
124 val = RREG32(rec->y_data_reg); in amdgpu_i2c_get_data()
125 val &= rec->y_data_mask; in amdgpu_i2c_get_data()
133 struct amdgpu_device *adev = drm_to_adev(i2c->dev); in amdgpu_i2c_set_clock()
134 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; in amdgpu_i2c_set_clock()
138 val = RREG32(rec->en_clk_reg) & ~rec->en_clk_mask; in amdgpu_i2c_set_clock()
139 val |= clock ? 0 : rec->en_clk_mask; in amdgpu_i2c_set_clock()
140 WREG32(rec->en_clk_reg, val); in amdgpu_i2c_set_clock()
146 struct amdgpu_device *adev = drm_to_adev(i2c->dev); in amdgpu_i2c_set_data()
147 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; in amdgpu_i2c_set_data()
151 val = RREG32(rec->en_data_reg) & ~rec->en_data_mask; in amdgpu_i2c_set_data()
152 val |= data ? 0 : rec->en_data_mask; in amdgpu_i2c_set_data()
153 WREG32(rec->en_data_reg, val); in amdgpu_i2c_set_data()
169 if (rec->mm_i2c && (amdgpu_hw_i2c == 0)) in amdgpu_i2c_create()
176 i2c->rec = *rec; in amdgpu_i2c_create()
177 i2c->adapter.owner = THIS_MODULE; in amdgpu_i2c_create()
178 i2c->adapter.class = I2C_CLASS_DDC; in amdgpu_i2c_create()
179 i2c->adapter.dev.parent = dev->dev; in amdgpu_i2c_create()
180 i2c->dev = dev; in amdgpu_i2c_create()
181 i2c_set_adapdata(&i2c->adapter, i2c); in amdgpu_i2c_create()
182 mutex_init(&i2c->mutex); in amdgpu_i2c_create()
183 if (rec->hw_capable && in amdgpu_i2c_create()
186 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), in amdgpu_i2c_create()
188 i2c->adapter.algo = &amdgpu_atombios_i2c_algo; in amdgpu_i2c_create()
189 ret = i2c_add_adapter(&i2c->adapter); in amdgpu_i2c_create()
193 /* set the amdgpu bit adapter */ in amdgpu_i2c_create()
194 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), in amdgpu_i2c_create()
195 "AMDGPU i2c bit bus %s", name); in amdgpu_i2c_create()
196 i2c->adapter.algo_data = &i2c->bit; in amdgpu_i2c_create()
197 i2c->bit.pre_xfer = amdgpu_i2c_pre_xfer; in amdgpu_i2c_create()
198 i2c->bit.post_xfer = amdgpu_i2c_post_xfer; in amdgpu_i2c_create()
199 i2c->bit.setsda = amdgpu_i2c_set_data; in amdgpu_i2c_create()
200 i2c->bit.setscl = amdgpu_i2c_set_clock; in amdgpu_i2c_create()
201 i2c->bit.getsda = amdgpu_i2c_get_data; in amdgpu_i2c_create()
202 i2c->bit.getscl = amdgpu_i2c_get_clock; in amdgpu_i2c_create()
203 i2c->bit.udelay = 10; in amdgpu_i2c_create()
204 i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ in amdgpu_i2c_create()
205 i2c->bit.data = i2c; in amdgpu_i2c_create()
206 ret = i2c_bit_add_bus(&i2c->adapter); in amdgpu_i2c_create()
208 DRM_ERROR("Failed to register bit i2c %s\n", name); in amdgpu_i2c_create()
224 WARN_ON(i2c->has_aux); in amdgpu_i2c_destroy()
225 i2c_del_adapter(&i2c->adapter); in amdgpu_i2c_destroy()
244 if (adev->i2c_bus[i]) { in amdgpu_i2c_fini()
245 amdgpu_i2c_destroy(adev->i2c_bus[i]); in amdgpu_i2c_fini()
246 adev->i2c_bus[i] = NULL; in amdgpu_i2c_fini()
260 if (!adev->i2c_bus[i]) { in amdgpu_i2c_add()
261 adev->i2c_bus[i] = amdgpu_i2c_create(dev, rec, name); in amdgpu_i2c_add()
275 if (adev->i2c_bus[i] && in amdgpu_i2c_lookup()
276 (adev->i2c_bus[i]->rec.i2c_id == i2c_bus->i2c_id)) { in amdgpu_i2c_lookup()
277 return adev->i2c_bus[i]; in amdgpu_i2c_lookup()
308 if (i2c_transfer(&i2c_bus->adapter, msgs, 2) == 2) { in amdgpu_i2c_get_byte()
333 if (i2c_transfer(&i2c_bus->adapter, &msg, 1) != 1) in amdgpu_i2c_put_byte()
344 if (!amdgpu_connector->router.ddc_valid) in amdgpu_i2c_router_select_ddc_port()
347 if (!amdgpu_connector->router_bus) in amdgpu_i2c_router_select_ddc_port()
350 amdgpu_i2c_get_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_ddc_port()
351 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_ddc_port()
353 val &= ~amdgpu_connector->router.ddc_mux_control_pin; in amdgpu_i2c_router_select_ddc_port()
354 amdgpu_i2c_put_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_ddc_port()
355 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_ddc_port()
357 amdgpu_i2c_get_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_ddc_port()
358 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_ddc_port()
360 val &= ~amdgpu_connector->router.ddc_mux_control_pin; in amdgpu_i2c_router_select_ddc_port()
361 val |= amdgpu_connector->router.ddc_mux_state; in amdgpu_i2c_router_select_ddc_port()
362 amdgpu_i2c_put_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_ddc_port()
363 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_ddc_port()
373 if (!amdgpu_connector->router.cd_valid) in amdgpu_i2c_router_select_cd_port()
376 if (!amdgpu_connector->router_bus) in amdgpu_i2c_router_select_cd_port()
379 amdgpu_i2c_get_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_cd_port()
380 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_cd_port()
382 val &= ~amdgpu_connector->router.cd_mux_control_pin; in amdgpu_i2c_router_select_cd_port()
383 amdgpu_i2c_put_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_cd_port()
384 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_cd_port()
386 amdgpu_i2c_get_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_cd_port()
387 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_cd_port()
389 val &= ~amdgpu_connector->router.cd_mux_control_pin; in amdgpu_i2c_router_select_cd_port()
390 val |= amdgpu_connector->router.cd_mux_state; in amdgpu_i2c_router_select_cd_port()
391 amdgpu_i2c_put_byte(amdgpu_connector->router_bus, in amdgpu_i2c_router_select_cd_port()
392 amdgpu_connector->router.i2c_addr, in amdgpu_i2c_router_select_cd_port()