Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,30 @@ NUT_ARG_WITH([linux_i2c], [build and install i2c drivers], [auto])
if test "${nut_with_linux_i2c}" != no; then
case ${target_os} in
linux* )
AC_CHECK_HEADER(
[linux/i2c-dev.h],
[AC_DEFINE([HAVE_LINUX_I2C_DEV_H], [1],
[Define to 1 if you have <linux/i2c-dev.h>.])]
)
AC_CHECK_HEADER(
[i2c/smbus.h],
[AC_DEFINE([HAVE_LINUX_SMBUS_H], [1],
[Define to 1 if you have <i2c/smbus.h>.])]
)
AC_CHECK_DECLS(
[i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data],
[i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data],
[nut_with_linux_i2c="yes"],
[nut_with_linux_i2c="no"],
[#include <stdio.h>
#ifdef HAVE_LINUX_I2C_DEV_H
#include <linux/i2c-dev.h>
#endif
#ifdef HAVE_LINUX_SMBUS_H
#include <i2c/smbus.h>
#endif
]
)
AC_SEARCH_LIBS([i2c_smbus_read_byte], [i2c])
;;
* )
nut_with_linux_i2c="no"
Expand Down
6 changes: 3 additions & 3 deletions docs/man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -620,16 +620,16 @@ endif

HTML_MODBUS_MANS = phoenixcontact_modbus.html

SRC_LINUX_I2C_PAGES = asem.txt
SRC_LINUX_I2C_PAGES = asem.txt pijuice.txt
if WITH_MANS
MAN_LINUX_I2C_PAGES = asem.8
MAN_LINUX_I2C_PAGES = asem.8 pijuice.8
endif

if WITH_LINUX_I2C
man8_MANS += $(MAN_LINUX_I2C_PAGES)
endif

HTML_LINUX_I2C_MANS = asem.html
HTML_LINUX_I2C_MANS = asem.html pijuice.html

# SOME_DRIVERS
endif
Expand Down
1 change: 1 addition & 0 deletions docs/man/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Drivers
- linkman:oneac[8]
- linkman:optiups[8]
- linkman:phoenixcontact_modbus[8]
- linkman:pijuice[8]
- linkman:powercom[8]
- linkman:powerman-pdu[8]
- linkman:powerpanel[8]
Expand Down
81 changes: 81 additions & 0 deletions docs/man/pijuice.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
PIJUICE(8)
==========

NAME
----
pijuice - driver for UPS in PiJuice HAT

NOTE
----
This man page only documents the hardware-specific features of the
*pijuice* driver. For information about the core driver, see
linkman:nutupsdrv[8].

NOTE: This manual page was hastily adapted from related `asem` driver
manpage based on information from the original pull request, and so
may not fully apply to PiJuice HAT, patches from experts are welcome.

SUPPORTED HARDWARE
------------------
The *pijuice* driver supports the portable PiJuice HAT UPS for Raspberry Pi
embedded PCs.

EXTRA ARGUMENTS
---------------

The required parameter for this driver is the I2C bus name:

*port*='dev-node'::
On the PiJuice HAT, this should be `/dev/i2c-1`.

INSTALLATION
------------
NOTE: This section was copied from `asem` driver manpage and may not fully
apply to PiJuice HAT, patches are welcome.

This driver is specific to the Linux I2C API, and requires the lm_sensors
libi2c-dev or its equivalent to compile.

Beware that the SystemIO memory used by the I2C controller is reserved by ACPI.
If only a native I2C driver (e.g. i2c_i801, as of 3.5.X Linux kernels) is
available, then you'll need to relax the ACPI resources check. For example, you
can boot with the `acpi_enforce_resources=lax` option.

//////////////////////////////////////////
Optional: use DIAGNOSTICS to describe troubleshooting techniques that are
longer than what can be conveniently described in the driver error messages.

DIAGNOSTICS
-----------

//////////////////////////////////////////

KNOWN ISSUES AND BUGS
---------------------
NOTE: This section was copied from `asem` driver manpage and may not fully
apply to PiJuice HAT, patches are welcome.

The driver shutdown function is not implemented, so other arrangements must be
made to turn off the UPS.

AUTHORS
-------
Andrew Anderson <aander07@gmail.com>

SEE ALSO
--------

The core driver:
~~~~~~~~~~~~~~~~
linkman:nutupsdrv[8]

Internet resources:
~~~~~~~~~~~~~~~~~~~
Initial pull requests adding this driver:

* https://github.com/networkupstools/nut/pull/730
* https://github.com/PiSupply/PiJuice/issues/124

Product home page: https://uk.pi-supply.com/products/pijuice-standard

The NUT (Network UPS Tools) home page: http://www.networkupstools.org/
3 changes: 3 additions & 0 deletions docs/nut.dict
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,8 @@ PhaseWin
PhoenixContact
PhoenixTec
Phoenixtec
Pi
PiJuice
Plesser
PnP
Pohle
Expand Down Expand Up @@ -1970,6 +1972,7 @@ phoenixcontact
picocom
pid
pidpath
pijuice
pinout
pinouts
pkg
Expand Down
7 changes: 5 additions & 2 deletions drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SERIAL_USB_DRIVERLIST = \
NEONXML_DRIVERLIST = netxml-ups
MACOSX_DRIVERLIST = macosx-ups
MODBUS_DRIVERLIST = phoenixcontact_modbus
LINUX_I2C_DRIVERLIST = asem
LINUX_I2C_DRIVERLIST = asem pijuice

# distribute all drivers, even ones that are not built by default
EXTRA_PROGRAMS = $(SERIAL_DRIVERLIST) $(SNMP_DRIVERLIST) $(USB_DRIVERLIST) $(SERIAL_USB_DRIVERLIST) $(NEONXML_DRIVERLIST) $(MACOSX_DRIVERLIST)
Expand Down Expand Up @@ -128,6 +128,7 @@ mge_utalk_SOURCES = mge-utalk.c
microdowell_SOURCES = microdowell.c
oneac_SOURCES = oneac.c
optiups_SOURCES = optiups.c
pijuice_SOURCES = pijuice.c
powercom_SOURCES = powercom.c
powercom_LDADD = $(LDADD) -lm
powerpanel_SOURCES = powerpanel.c powerp-bin.c powerp-txt.c
Expand Down Expand Up @@ -241,9 +242,11 @@ macosx_ups_SOURCES = macosx-ups.c
phoenixcontact_modbus_SOURCES = phoenixcontact_modbus.c
phoenixcontact_modbus_LDADD = $(LDADD_DRIVERS) $(LIBMODBUS_LIBS)

# Asem
# Linux I2C drivers
asem_LDADD = $(LDADD_DRIVERS)
asem_SOURCES = asem.c
pijuice_LDADD = $(LDADD_DRIVERS)
pijuice_SOURCES = pijuice.c

# nutdrv_qx USB/Serial
nutdrv_qx_SOURCES = nutdrv_qx.c
Expand Down
7 changes: 4 additions & 3 deletions drivers/asem.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
so you need to boot with acpi_enforce_resources=lax option.
*/

/* Depends on i2c-dev.h, Linux only */
#include "main.h"

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
/* Depends on i2c-dev.h, Linux only */
#include <linux/i2c-dev.h>

#include "main.h"
#include <sys/ioctl.h>

#ifndef __STR__
# define __STR__(x) #x
Expand Down
Loading