Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2014 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs
0023  */
0024 #include "pad.h"
0025 #include "aux.h"
0026 #include "bus.h"
0027 
0028 void
0029 g94_i2c_pad_mode(struct nvkm_i2c_pad *pad, enum nvkm_i2c_pad_mode mode)
0030 {
0031     struct nvkm_subdev *subdev = &pad->i2c->subdev;
0032     struct nvkm_device *device = subdev->device;
0033     const u32 base = (pad->id - NVKM_I2C_PAD_HYBRID(0)) * 0x50;
0034 
0035     switch (mode) {
0036     case NVKM_I2C_PAD_OFF:
0037         nvkm_mask(device, 0x00e50c + base, 0x00000001, 0x00000001);
0038         break;
0039     case NVKM_I2C_PAD_I2C:
0040         nvkm_mask(device, 0x00e500 + base, 0x0000c003, 0x0000c001);
0041         nvkm_mask(device, 0x00e50c + base, 0x00000001, 0x00000000);
0042         break;
0043     case NVKM_I2C_PAD_AUX:
0044         nvkm_mask(device, 0x00e500 + base, 0x0000c003, 0x00000002);
0045         nvkm_mask(device, 0x00e50c + base, 0x00000001, 0x00000000);
0046         break;
0047     default:
0048         WARN_ON(1);
0049         break;
0050     }
0051 }
0052 
0053 static const struct nvkm_i2c_pad_func
0054 g94_i2c_pad_s_func = {
0055     .bus_new_4 = nv50_i2c_bus_new,
0056     .aux_new_6 = g94_i2c_aux_new,
0057     .mode = g94_i2c_pad_mode,
0058 };
0059 
0060 int
0061 g94_i2c_pad_s_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad)
0062 {
0063     return nvkm_i2c_pad_new_(&g94_i2c_pad_s_func, i2c, id, ppad);
0064 }
0065 
0066 static const struct nvkm_i2c_pad_func
0067 g94_i2c_pad_x_func = {
0068     .bus_new_4 = nv50_i2c_bus_new,
0069     .aux_new_6 = g94_i2c_aux_new,
0070 };
0071 
0072 int
0073 g94_i2c_pad_x_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad)
0074 {
0075     return nvkm_i2c_pad_new_(&g94_i2c_pad_x_func, i2c, id, ppad);
0076 }