imx51_i2c.c revision 1.1
11.1Shkenken/* $NetBSD: imx51_i2c.c,v 1.1 2014/07/25 07:07:47 hkenken Exp $ */ 21.1Shkenken 31.1Shkenken/* 41.1Shkenken * Copyright (c) 2012 Genetec Corporation. All rights reserved. 51.1Shkenken * Written by Hashimoto Kenichi for Genetec Corporation. 61.1Shkenken * 71.1Shkenken * Redistribution and use in source and binary forms, with or without 81.1Shkenken * modification, are permitted provided that the following conditions 91.1Shkenken * are met: 101.1Shkenken * 1. Redistributions of source code must retain the above copyright 111.1Shkenken * notice, this list of conditions and the following disclaimer. 121.1Shkenken * 2. Redistributions in binary form must reproduce the above copyright 131.1Shkenken * notice, this list of conditions and the following disclaimer in the 141.1Shkenken * documentation and/or other materials provided with the distribution. 151.1Shkenken * 161.1Shkenken * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 171.1Shkenken * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181.1Shkenken * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191.1Shkenken * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 201.1Shkenken * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211.1Shkenken * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221.1Shkenken * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231.1Shkenken * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241.1Shkenken * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251.1Shkenken * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261.1Shkenken * SUCH DAMAGE. 271.1Shkenken */ 281.1Shkenken 291.1Shkenken#include <sys/cdefs.h> 301.1Shkenken__KERNEL_RCSID(0, "$NetBSD: imx51_i2c.c,v 1.1 2014/07/25 07:07:47 hkenken Exp $"); 311.1Shkenken 321.1Shkenken#include <sys/param.h> 331.1Shkenken#include <sys/bus.h> 341.1Shkenken#include <sys/device.h> 351.1Shkenken 361.1Shkenken#include "opt_imx.h" 371.1Shkenken 381.1Shkenken#include <arm/imx/imxi2cvar.h> 391.1Shkenken#include <arm/imx/imx51reg.h> 401.1Shkenken#include <arm/imx/imx51var.h> 411.1Shkenken#include <arm/imx/imx51_ccmvar.h> 421.1Shkenken 431.1Shkenkenint 441.1Shkenkenimxi2c_match(device_t parent, cfdata_t cf, void *aux) 451.1Shkenken{ 461.1Shkenken if (strcmp(cf->cf_name, "imxi2c") == 0) 471.1Shkenken return 1; 481.1Shkenken 491.1Shkenken return 0; 501.1Shkenken} 511.1Shkenken 521.1Shkenkenvoid 531.1Shkenkenimxi2c_attach(device_t parent, device_t self, void *aux) 541.1Shkenken{ 551.1Shkenken struct axi_attach_args * aa = aux; 561.1Shkenken struct imxi2c_softc *sc = device_private(self); 571.1Shkenken struct i2cbus_attach_args iba; 581.1Shkenken 591.1Shkenken imxi2c_attach_common(parent, self, 601.1Shkenken aa->aa_iot, aa->aa_addr, aa->aa_size, aa->aa_irq, 0); 611.1Shkenken 621.1Shkenken imxi2c_set_freq(self, imx51_get_clock(IMX51CLK_PERCLK_ROOT), 400000); 631.1Shkenken 641.1Shkenken memset(&iba, 0, sizeof(iba)); 651.1Shkenken iba.iba_tag = &sc->sc_i2c; 661.1Shkenken config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print); 671.1Shkenken} 68