Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] New 4.14 UM-kernel for EM-2060 #7

Open
wants to merge 95 commits into
base: for-opinicus/stable-4.14.y
Choose a base branch
from

Conversation

oliv3r
Copy link

@oliv3r oliv3r commented Apr 6, 2018

These are our patches ontop of the 4.14.32 LTS kernel. This PR is for review purposes only to review our specific UM patches, as this branch will become the new 'master/release' branch.

EM-2060

oliv3r and others added 30 commits April 5, 2018 10:35
Commit 2ad6f30 ("ASoC: sun4i-i2s: Add quirks to handle a31 compatible")
added support for reset control but support for sun4i was overlooked. For
these older SoC's it is quite common not have this reset control.

The reset control is first requested, and later checked if it IS_ERR.
If however there is no reset control configured, we can get NULL and
thus the checks pass with a NULL pointer passed the functions
afterwards.

Lets use IS_ERR_OR_NULL to ensure the reset control is only
(de)asserted when we actually have a valid reset control.

Signed-off-by: Olliver Schinagl <[email protected]>
The current Makefile has mixed tabs and spaces. This patch causes no
binary changes.

Signed-off-by: Olliver Schinagl <[email protected]>
This patch was inspired by touchscreen_of where a few helper functions
are used to help in parsing various devicetree parameters and thus
offing a standard way for common items.

Here we add support for the first common parameter, 'rotate' which
determines the initial rotation of a screen.

In the future, this can be expanded to also add support for
width/height for example and others as well.

Signed-off-by: Olliver Schinagl <[email protected]>
There are situations, where the bootloader is relied on to prepare the
display. For example to show a splash screen. Some drivers however
clear the framebuffer during probing and it may be a while before linux
has the chance to show something on the screen. This is experienced by
the user as a blank screen for potentially long seconds.

This patch adds a generic parameter to the framebuffer devicetree
parser to allow the user to explicitly avoid clearing the framebuffer
during load.

Signed-off-by: Olliver Schinagl <[email protected]>
Alphabetize headers in fbsysfs.c, no functional changes where performed.

Signed-off-by: Olliver Schinagl <[email protected]>
The simple_strtoul function appears to have been deprecated, replace
the easy invocations of simple_strtoul. Two invocations remain which
uses the end pointer of simple_strtoul.

Signed-off-by: Olliver Schinagl <[email protected]>
Currently, we pass any value received from sysfs along to a driver
though it is only claimed that 0 - 3 are valid choices. This patch adds
input validation herein to ensure only the allowed parameters are
actually pushed along the chain.

Signed-off-by: Olliver Schinagl <[email protected]>
The rotation interface supports rotation angles from 0 - 3. While this
works great for machines, under normal circumstances, humans prefer to
use 0, 90, 180 and 270 degree's as parameters for their rotation.

This patch allows the human readable factors as input to the sysfs
interface and translates them to their rotation counterparts.

Signed-off-by: Olliver Schinagl <[email protected]>
While the documented parameters, 0, 1, 2 and 3 for rotation are well
understood, it makes sense to also support the 'human' parameters, 90,
180 and 270 degree's of rotation support.

Signed-off-by: Olliver Schinagl <[email protected]>
We should abort probe if we cannot talk to the display. This
prevents creating a fb device which does not work and prevents
a lot of i2c communication error messages as a consequence.

Signed-off-by: Olliver Schinagl <[email protected]>
For autoprobing to work on devicetree based systems, the compatible
name is used when probing i2c devices. Because the device id is now not
the same, the ssd1307 does not get autoprobed.

By renaming the device id, autoprobing is now functional on devicetree
based systems.

Signed-off-by: Olliver Schinagl <[email protected]>
The ssd1307fb driver is a little inconsistent in the debug messages.
Common is to not capitalize the first letter and to not add any periods
etc at the end. Also add a quick shortcut to access the device
structure shortening our error messages.

Finally take this cleanup opportunity to add the missing device.h
header.

Signed-off-by: Olliver Schinagl <[email protected]>
When we fail to send messages to our display, we print an error.
However this 'spam' can continue heavily and add a heavy load on the
system just to print these messages.

Lets use the ratelimited variant of dev_err to lessen the system load.

Signed-off-by: Olliver Schinagl <[email protected]>
Some minor cleanup to group the fb_info.fix entries together.

Signed-off-by: Olliver Schinagl <[email protected]>
THe virtual resolution and line-length are attributes of the X and Y
resolution, which are determined by the width/height of the display.

Currently it is all directly determined from the width/height
parameter. The width and height never change of the display, but the X,
Y resolution can change when rotating the display.

It thus makes more sense to determine the line length and virtual
parameters from their resolution counterparts and not the display
dimensions.

Signed-off-by: Olliver Schinagl <[email protected]>
The ssd1307fb driver has a few magic values that an happily be moved to
some common defines improving readability.

Signed-off-by: Olliver Schinagl <[email protected]>
In commit c89eacf ("fbdev: ssd1307fb: Unify init code and obtain hw
specific bits from DT") the need for the forward declaration struct
ssd1307fb_par was removed with the removal of the init/remove
ssd1307fb_ops. Clear up the lingering unused forward declaration.

Signed-off-by: Olliver Schinagl <[email protected]>
To support rotation from sysfs, we need to implement set_par at the
least. According to the skeletonfb driver the set_par:

   Again if you can't change the resolution you don't need this function.

   However, even if your hardware does not support mode changing,
   a set_par might be needed to at least initialize the hardware to
   a known working state, especially if it came back from another
   process that also modifies the same hardware, such as X.

Further more, after heavy usage in the last 3 years, we noticed that
the scanout related registers can become corrupted by the hardware
under certain conditions resulting in shifted scanouts.

We thus concluded that we need to re-set the scan-addressing registers
after certain operations, such as rotation.

This patch thus moves these critical settings from init to set_par.
Since we do not need to validate any 'var' parameters, the check_var
function has been omitted for now.

Signed-off-by: Olliver Schinagl <[email protected]>
Currently, we 'enable' the display in our last step of init. The
enable mend of the display however should be the very last step of our
probing sequence, e.g. just before saying 'driver loaded successfully',
as this is the time we are 'ready'.

This patch uses the later introduced ssd1307fb_(un)blank function to
achieve this.

Further more, we want to guarantee that the display is in its off state
during initialization, so after reset, we guarantee that the display is
off.

Signed-off-by: Olliver Schinagl <[email protected]>
The ssd130x series of chips are very flexible, allowing customers to
use any layout to connect the LCD to the PCB. We can use this in
combination with the different scan-out parameters to flip and rotate
the display at will. E.g. A X and Y flip results in a 180 degree
rotation. Changing the scanout from horizontal to vertical rotates by
90 degree's. This thus gives us hardware accelerated rotation support.

Signed-off-by: Olliver Schinagl <[email protected]>
The ssd1307fb can in theory support 90 and 270 degree rotations.
However this has not been thoroughly tested yet and there is more
to it then initially assumed (just changing the scanout to vertical may
not be enough). Due to the lack of time to properly research and
implement this, only allow 0 and 180 rotations for now.

Signed-off-by: Olliver Schinagl <[email protected]>
Commit 6e37682 ("fbdev/ssd1307fb: clear screen in probe") in
combination with commit fdde1a8 ("fbdev: ssd1307fb: Make reset gpio
devicetree property optiona") changed the previous default behavior of
keeping the display active. This for example is a feature that is used
to show a splash screen from u-boot and leave it on the controller
until linux/an application is ready to show its own information.

We thus let the devicetree control this behavior via the
no-clear-on-probe flag, which skips the clearing of the framebuffer and
thus keeps a splash screen on the device.

The default is left to clear the screen (unset in the devicetree) as
the new default does make sense. If u-boot does not initialize the
screen and does not show a splash-screen garbled displays can occur.

Signed-off-by: Olliver Schinagl <[email protected]>
The PCA9570 is the most basic of the pca957x series.

It is a 4 bit i2c gpio expander without an interrupt line.

Signed-off-by: Olliver Schinagl <[email protected]>
Currently, the driver always successfully manages to load,
even if there is no actual chip present (or communication
is not possible over i2c).

This has the side-effect, that the node is always available in
sysfs, and writing data to it which results in i2c errors.

To improve behavior here, we try to read the first byte from
the device, and if this was okay, we at least know there is some
device on the bus, even though we do not know which one.

Signed-off-by: Olliver Schinagl <[email protected]>
Re-order headers so they are in alphabetical order.

Signed-off-by: Olliver Schinagl <[email protected]>
This patch adds some more defines so that the driver can receive
a little more future work. These new defines are then used throughout the
existing code the remove some magic values.

This patch does not produce any binary changes.

Signed-off-by: Olliver Schinagl <[email protected]>
Currently, we blast sleep mode or 0 into the mode1 register, without
taking notice of whatever was in it before.

Lets be a bit more proper here and read the register and modify only
the bit which we are concerned.

Signed-off-by: Olliver Schinagl <[email protected]>
Let's improve readability a little bit by reordering initial LED output
configuration.

Signed-off-by: Olliver Schinagl <[email protected]>
This patch does some whitespace fixing to make the entire driver more
consistent, especially with regards to alignment. Because of this it
also reduces quite some of the checkpatch warnings.

This did came at the cost of some minor 80 char warnings however to satisfy
the alignment and improve readability.

This patch does not introduce any binary changes.

Signed-off-by: Olliver Schinagl <[email protected]>
The PCA963x series of chips have several operating modes controlled via
the LEDOUT register. LDR controls whether the leds are completely off
(0x0), completely on (0x1), only controlled via the PWM registers (0x2)
or a special 'grouped' mode (0x3).

In the grouped mode, the leds can either blink, or PWM in
synchronization. Since the LED framework currently does not support
linked LEDs and thus we cannot PWM in synchronization, set the default group
to blink, to ensure that hardware based blinking at least is synchronized
when blinking.

Signed-off-by: Olliver Schinagl <[email protected]>
oliv3r added 10 commits April 5, 2018 11:25
By replacing the magic hardcoded bit masks with GENMASK we can improve
readability quite a bit. By also changing the order of shifting and
masking, we can actually use a GENMASK as described in the datasheet
making the masks even more obvious and easier to read.

Furthermore we replace some magic values in the code with defined a
getter in turn use it to improve readability.

This patch does not have any functional changes.

Signed-off-by: Olliver Schinagl <[email protected]>
In sun4i_drv_unbind the drm struct is retrieved and passed to
drm_dev_unregister. Since however the drm structure is never set in
during bind, we get a NULL pointer dereference error and the following
stacktrace.

[<b03723a2>] (drm_dev_unregister) from [<af811011>] (sun4i_drv_unbind+0xc/0x2c [sun4i_drm])
[<af811011>] (sun4i_drv_unbind [sun4i_drm]) from [<b0386c29>] (take_down_master.part.0+0xd/0x1c)
[<b0386c29>] (take_down_master.part.0) from [<b0386d47>] (component_del+0xb7/0xbc)
[<b0386d47>] (component_del) from [<af8e60bb>] (sun4i_backend_remove+0xa/0x14 [sun4i_backend])
[<af8e60bb>] (sun4i_backend_remove [sun4i_backend]) from [<b038befd>] (platform_drv_remove+0x11/0x20)
[<b038befd>] (platform_drv_remove) from [<b038b049>] (device_release_driver_internal+0xd1/0x134)
[<b038b049>] (device_release_driver_internal) from [<b038b0e3>] (driver_detach+0x2f/0x5c)
[<b038b0e3>] (driver_detach) from [<b038a48d>] (bus_remove_driver+0x31/0x88)
[<b038a48d>] (bus_remove_driver) from [<af8e6a65>] (sun4i_backend_platform_driver_exit+0x8/0x5a3 [sun4i_backend])
[<af8e6a65>] (sun4i_backend_platform_driver_exit [sun4i_backend]) from [<b017c753>] (SyS_delete_module+0x117/0x154)
[<b017c753>] (SyS_delete_module) from [<b0106661>] (ret_fast_syscall+0x1/0x5a)
Code: f2cb 007e f5ea fbc5 (696b) f8d3
---[ end trace c92c06a17cdbc6e9 ]---

By setting the drm data into the device structure we fix this error.

Signed-off-by: Olliver Schinagl <[email protected]>
While the tmds clock is configured using set_rate whenever we
use/change it, we never properly 'enable' or 'disable' it throwing off
our ref-counters. The reason it works is because it is an ungated clock
and thus always runs whenever its parent runs.

Add the enable/disable calls to the tmds clock to ensure our
ref-counters play nicely.

Signed-off-by: Olliver Schinagl <[email protected]>
In the tmds clock driver, we current assign the counter value to a
Boolean check. When reading this code as an outsider it is not
immediately obvious what is happening, as the counter (d) initially
appears to never become 0. After closer inspection it becomes obvious
that the always positive counter is used to toggle the Boolean only at
a certain case.

Unfortunately there does not seem to be any added benefit from using
the more confusing value of d over using 'true' since there is no
direct relation to 'd'. This now makes the code a little more obvious
and easier to read.

Signed-off-by: Olliver Schinagl <[email protected]>
The ddc items can be consolidated more into one place.

Signed-off-by: Olliver Schinagl <[email protected]>
The fifo_transfer call currently makes an assumption on the clockrate
of the hdmi-i2c bus. However this assumption is based on the fact that
the clockrate is exactly what we request, e.g. if we set the rate to 100 kHz
the clock runs on exactly 100 kHz. This unfortunately is not exactly
true, as the actual rate depends on the parents and we may end up with
a slower clock. Further more if the clock changes from the 100 kHz now
this assumption may also not hold.

The remedy is easily fixed by asking the clk framework the actual
clockrate, with adding 8 clocks (1 byte) as a safety margin.

Further more, in case of error, it really helps to know that this
timeout has occurred so add a print statement for that.

Finally, the variable was renamed to more accurately tell us what it is,
a byte time in micro seconds, not nano seconds.

Signed-off-by: Olliver Schinagl <[email protected]>
The HDMI-I2C block has a bus busy indicator, which indicates whether
the bus is busy or not. Make use of this to check if the bus is busy
before attempting to transmit. This prevents any unnoticed errors when
unable being to transmit due to a busy bus.

Signed-off-by: Olliver Schinagl <[email protected]>
With this patch, the hdmi-i2c peripheral is split off into its own
identity. By doing so, this gives board designers and users various new
uses.

It is now possible to use the ddc-i2c-bus property on the
display node to actually choose an I2C controller. E.g. if a board
designer chooses to use a different I2C controller for the EDID eeprom,
they are free to do so.

The HDMI-I2C controller node can now have various frequency settings.
In other words if due to layout/routing issues the default clock of 100
kHz is to high for stable operation, the clock could be lowered to a
supported frequency for that board.

Supporting peripherals on the other end of the bus. Some monitors
support various sensors or controls over the I2C bus. Think monitor
orientation, back light, brightness, touch etc control. By having a separated
node it becomes possible to configure these devices. Note, that this is
a bad example in the sense that while a monitor (HDMI) supports hot plugging,
I2C device detection does not. This is a potentially future feature,
e.g. a hotplug event re-checks the bus and re-probes I2C drivers on
the bus.

Not working properly: Legacy clocking. For some reason when using an old
devicetree the clocks are not setup properly.

A few future improvements are left TODO:
* Re-probe i2c bus after hot plugging of the HDMI connector.
* I2C clock recovery

Signed-off-by: Olliver Schinagl <[email protected]>
As the Lime2 uses the internal HDMI I2C bus for its EDID, explicitly
configure it as so in the devicetree.

Signed-off-by: Olliver Schinagl <[email protected]>
…s/input', 'for-opinicus/leds', 'for-opinicus/pwm', 'for-opinicus/rtc', 'for-opinicus/regulator', 'for-opinicus/serial', 'for-opinicus/fbdev' and 'for-opinicus/hdmi' into opinicus-4.14-0

* for-opinicus/asoc:
  ASoC: sun4i-is: also check for NULL on reset pin request

* for-opinicus/gpio:
  gpio: pca953x: add support for the NXP pca9570

* for-opinicus/input:
  input: edt-ft5x06: force touchscreen to remain active
  input: edt-ft5x06: add polldev as an option
  input: edt-ft5x06: take into account the number of fingers
  input: edt-ft5x06: fix multi-touch handling
  input: edt-ft5x06: sanity check on input
  input: edt-ft5x06: silence deferral error
  input: edt-ft5x06: use less magic and more defines
  input: edt-ft5x06: shorten defines
  input: edt-ft5x06: minor consistency cleanup/line length reduction
  input: edt-ft5x06: fix some whitespace/ident issues
  input: edt-ft5x06: only enable the irq when needed
  input: edt-ft5x06: cleanup headers
  input: edt-ft5x06: add support for the ft5426 controller
  input: edt-ft5x06: group r, w and rw functions
  input: of_touchscreen: add support for minimum sizes
  input: of_touchscreen: rename touchscreen-size-[xy]
  input: of_touchscreen: shorten variable names

* for-opinicus/leds:
  leds: pca963x: set DMBLNK as default during probe
  leds: pca963x: remove whitespace and checkpatch problems
  leds: pca963x: refactor initial led output a little
  leds: pca963x: save mode when setting power_state
  leds: pca963x: add defines and remove some magic values
  leds: pca963x: alphabetize headers
  leds: pca963x: abort probe if device is not connected

* for-opinicus/pwm:
  pwm: core: do not block apply->state on period

* for-opinicus/rtc:
  rtc: sun6i: add missing header

* for-opinicus/regulator:
  power: supply: axp288: use the BIT() macro
  power: supply: axp20x: add missing include bitops.h
  mfd: axp20x: use explicit bit defines
  mfd: axp20x: fixup includes
  regulator: dts: set proper lradc vref on OLinuXino Lime2
  regulator: dts: add full voltage range to LDO4 on the Lime2
  regulator: dts: enable soft-start and ramp delay for the OLinuXino Lime2
  regulator: axp20x: add software based soft_start for LDO3
  regulator: axp20x: add support for set_ramp_delay
  regulator: core: enable power when setting up constraints
  regulator: axp20x: name voltage ramping define properly
  regulator: axp20x: use defines for masks

* for-opinicus/serial:
  serial: 8250: expand debug ability of the irq handler
  serial: 8250: Only confirm handled interrupts on supported ones
  serial: 8250_dw: Make register access consistent
  serial: 8250_dw: Use serial port assessor wrapper
  serial: 8250: Do not treat the IIR register as a bitfield
  serial: 8250: Minor cleanups
  serial: 8250: Replace asm/irq with linux/irqreturn, linux/interrupt

* for-opinicus/fbdev: (21 commits)
  fbdev: ssd1307fb: Do not always clear the display on boot
  fbdev: ssd1307fb: Limit to support 0 - 180 rotation only
  fbdev: ssd1307fb: Add hardware accelerated rotation support
  fbdev: ssd1307fb: Ensure display is toggled properly
  fbdev: ssd1307fb: Ensure set_par can do bring-up
  fbdev: ssd1307fb: Remove unused forward declaration
  fbdev: ssd1307fb: Reduce magic values with defines
  fbdev: ssd1307fb: Use resolution instead of dimensions
  fbdev: ssd1307fb: cleanup: Group fb_info.fix
  fbdev: ssd1307fb: Use ratelimited error printing
  fbdev: ssd1307fb: Make output a little more consistent
  fbdev: ssd1307fb: Rename i2c device ids
  fbdev: ssd1307fb: Abort probe if we cannot talk to the display
  fbdev: sysfs: Add rotation in degrees support to validation
  fbdev: sysfs: Expand input validation to degree's
  fbdev: sysfs: Input validation
  fbdev: sysfs: Replace simple_strtoul with kstrtoul
  fbdev: sysfs: Sort headers
  fbdev: of: Add parameter to not clear screen on probe
  fbdev: of: Add of parsing helper
  ...

* for-opinicus/hdmi:
  arm/dts: Use hdmi_i2c node on the OLinuXino Lime2
  [WIP-do-not-merge] drm/sunxi: Split off hdmi-i2c as a separated driver
  drm: sun4i: check for i2c busy status
  drm/sun4i: make fifo_transfer more verbose in case of error
  drm/sun4i: i2c: consolidate ddc items
  drm/sun4i: make bool assignment explicit
  drm/sun4i: enable/disable the tmds clock on use
  drm/sun4i: Fix NULL pointer dereference at unbind
  drm/sun4i: improve header readability
  drm/sun4i: Fix Kconfig indenting
  drm/edid: Prevent NULL pointer deref when there is no I2C adapter
@oliv3r oliv3r force-pushed the opinicus-4.14-0 branch 2 times, most recently from 38c2368 to b1ca4f2 Compare April 6, 2018 14:05

The HDMI-I2C bus controller is implemented using a reasonably common I2C block
and can be used as a regular I2C device in a board layout. The only caveat
however is that the bus timing is dependent on the TMDS clock and thus the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: use interpunction :P

if (!i2c_np) {
dev_warn(dev, "Missing ddc-i2c-bus node in %pOF\n", node);

/* legacy devicetree's do not have the hdmi-i2c node */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: lose the ' in devicetree's


/* legacy devicetree's do not have the hdmi-i2c node */
if (hdmi->variant->has_ddc_parent_clk)
hdmi->i2c_drv = sun4i_hdmi_i2c_setup(dev, hdmi->base,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: add tab of {} for readability.

* detection is a bit hairy. The different ft5x06
* firmares around don't reliably implement the
* firmware's around don't reliably implement the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: ditch the ' in 'firmware's'

i2c_set_clientdata(client, tsdata);

if (client->irq) {
unsigned long irq_flags;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NITPICK: function gets very long, if/else clause logic could be put in separate functions?

oliv3r and others added 15 commits April 20, 2018 14:23
This patch does no functional change but to sort the headers.

Signed-off-by: Olliver Schinagl <[email protected]>
Some devices may want to bind their rfkill properties via devicetree
bindings. Enable this for rfkill-gpio.

Signed-off-by: Olliver Schinagl <[email protected]>
* for-opinicus/rfkill:
  net/rfkill/rfkill-gpio: Add support for devicetree bindings
  net/rfkill/rfkill-gpio: Alphabetize headers
When disabling, some PWM hardware IP leaves the pin in the state it
happens to be in at that very moment. To make sure it is in the
inactive state, the duty cycle is now set to 0 first, before PWM is
being disabled.

Solves: EMP-628
…15 Hz

EM-3628
There are better ways for modifying a module's parameters than changing the source code, but... modifying the refreshrate by means of a parameter to modprobe didn't work.
There are two old commits for this that were removed when the UM3 support was removed, but restoring those old commits didn't fix the slow display.
See:
- jedi-build commit 1832dc6831fd48316caac04dfd6d4ce54e859d5d
- um-kernel commit 5f1b51f7f26a36deafce1f1d3e880bec63bd2765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants