Re: svn commit: r310172 - in head/sys/mips: conf ingenic

2016-12-19 Thread Andriy Gapon
On 16/12/2016 22:04, Jared McNeill wrote:
> Log:
>   Add support for Ingenic JZ4780 SMBus controller.

Just a note that it looks, swims and quacks like an I²C (I2C / IIC) controller 
:-)

>   Reviewed by:kan
>   Relnotes:   yes
>   Differential Revision:  https://reviews.freebsd.org/D8793
> 
> Added:
>   head/sys/mips/ingenic/jz4780_smb.c   (contents, props changed)
>   head/sys/mips/ingenic/jz4780_smb.h   (contents, props changed)
> Modified:
>   head/sys/mips/conf/JZ4780
>   head/sys/mips/ingenic/files.jz4780


-- 
Andriy Gapon
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r310172 - in head/sys/mips: conf ingenic

2016-12-16 Thread Jared McNeill
Author: jmcneill
Date: Fri Dec 16 20:04:56 2016
New Revision: 310172
URL: https://svnweb.freebsd.org/changeset/base/310172

Log:
  Add support for Ingenic JZ4780 SMBus controller.
  
  Reviewed by:  kan
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D8793

Added:
  head/sys/mips/ingenic/jz4780_smb.c   (contents, props changed)
  head/sys/mips/ingenic/jz4780_smb.h   (contents, props changed)
Modified:
  head/sys/mips/conf/JZ4780
  head/sys/mips/ingenic/files.jz4780

Modified: head/sys/mips/conf/JZ4780
==
--- head/sys/mips/conf/JZ4780   Fri Dec 16 19:49:22 2016(r310171)
+++ head/sys/mips/conf/JZ4780   Fri Dec 16 20:04:56 2016(r310172)
@@ -75,6 +75,9 @@ deviceext_resources
 
 device gpio
 
+device iicbus
+device iic
+
 device scbus
 device da
 

Modified: head/sys/mips/ingenic/files.jz4780
==
--- head/sys/mips/ingenic/files.jz4780  Fri Dec 16 19:49:22 2016
(r310171)
+++ head/sys/mips/ingenic/files.jz4780  Fri Dec 16 20:04:56 2016
(r310172)
@@ -4,6 +4,7 @@ mips/ingenic/jz4780_dwc_fdt.c   optional d
 mips/ingenic/jz4780_ehci.c optional ehci
 mips/ingenic/jz4780_mmc.c  optional mmc
 mips/ingenic/jz4780_ohci.c optional ohci
+mips/ingenic/jz4780_smb.c  optional iicbus
 mips/ingenic/jz4780_uart.c optional uart
 
 mips/ingenic/jz4780_clock.cstandard

Added: head/sys/mips/ingenic/jz4780_smb.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/mips/ingenic/jz4780_smb.c  Fri Dec 16 20:04:56 2016
(r310172)
@@ -0,0 +1,480 @@
+/*-
+ * Copyright (c) 2016 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Ingenic JZ4780 SMB Controller
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "iicbus_if.h"
+
+#defineJZSMB_TIMEOUT   ((300UL * hz) / 1000)
+
+#defineJZSMB_SPEED_STANDARD10
+#defineJZSMB_SETUP_TIME_STANDARD   300
+#defineJZSMB_HOLD_TIME_STANDARD400
+#defineJZSMB_PERIOD_MIN_STANDARD   4000
+#defineJZSMB_PERIOD_MAX_STANDARD   4700
+
+#defineJZSMB_SPEED_FAST40
+#defineJZSMB_SETUP_TIME_FAST   450
+#defineJZSMB_HOLD_TIME_FAST450
+#defineJZSMB_PERIOD_MIN_FAST   600
+#defineJZSMB_PERIOD_MAX_FAST   1300
+
+#defineJZSMB_HCNT_BASE 8
+#defineJZSMB_HCNT_MIN  6
+#defineJZSMB_LCNT_BASE 1
+#defineJZSMB_LCNT_MIN  8
+
+static inline int
+tstohz(const struct timespec *tsp)
+{
+   struct timeval tv;
+
+   TIMESPEC_TO_TIMEVAL(, tsp);
+   return (tvtohz());
+}
+
+static struct ofw_compat_data compat_data[] = {
+   { "ingenic,jz4780-i2c", 1 },
+   { NULL, 0 }
+};
+
+static struct resource_spec jzsmb_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
+   { -1, 0 }
+};
+
+struct jzsmb_softc {
+   struct resource *res;
+   struct mtx  mtx;
+   clk_t   clk;
+   device_tiicbus;
+   int busy;
+   uint32_ti2c_freq;
+   uint64_t