Advertisement
danielhilst

imx6q-pads.el

Nov 6th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 2.26 KB | None | 0 0
  1. ;; Helpers for https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/fsl,imx6q-pinctrl.txt
  2. (setq lexical-binding t)
  3. (setq imx6q-pad-options '(
  4.                           (PAD_CTL_HYS                      (1 . 16))
  5.                           (PAD_CTL_PUS_100K_DOWN           (0 . 14))
  6.                           (PAD_CTL_PUS_47K_UP              (1 . 14))
  7.                           (PAD_CTL_PUS_100K_UP             (2 . 14))
  8.                           (PAD_CTL_PUS_22K_UP              (3 . 14))
  9.                           (PAD_CTL_PUE                     (1 . 13))
  10.                           (PAD_CTL_PKE                     (1 . 12))
  11.                           (PAD_CTL_ODE                     (1 . 11))
  12.                           (PAD_CTL_SPEED_LOW               (1 . 6))
  13.                           (PAD_CTL_SPEED_MED               (2 . 6))
  14.                           (PAD_CTL_SPEED_HIGH              (3 . 6))
  15.                           (PAD_CTL_DSE_DISABLE             (0 . 3))
  16.                           (PAD_CTL_DSE_240ohm              (1 . 3))
  17.                           (PAD_CTL_DSE_120ohm              (2 . 3))
  18.                           (PAD_CTL_DSE_80ohm               (3 . 3))
  19.                           (PAD_CTL_DSE_60ohm               (4 . 3))
  20.                           (PAD_CTL_DSE_48ohm               (5 . 3))
  21.                           (PAD_CTL_DSE_40ohm               (6 . 3))
  22.                           (PAD_CTL_DSE_34ohm               (7 . 3))
  23.                           (PAD_CTL_SRE_FAST                (1 . 0))
  24.                           (PAD_CTL_SRE_SLOW                (0 . 0))
  25.                           ))
  26.  
  27. (defun imx6q-get-option-bits (option)
  28.   (let ((bits (car (car (cdr (assoc option imx6q-pad-options))))))
  29.     (if bits
  30.         bits
  31.       (error "Can't find option %s" option))))
  32.  
  33. (defun imx6q-get-option-shift (option)
  34.   (let ((shift (cdr (car (cdr (assoc option imx6q-pad-options))))))
  35.     (if shift
  36.         shift
  37.       (error "Can't find option %s" option))))
  38.  
  39. (defun imx6q-get-option-value (option)
  40.   (lsh (imx6q-get-option-bits option)
  41.        (imx6q-get-option-shift option)))
  42.  
  43. (defun imx6q-get-mask (&rest options)
  44.   (let ((opt-list nil))
  45.     (dolist (opt options)
  46.       (push (imx6q-get-option-value opt) opt-list))
  47.     (format "0x%x" (apply 'logior opt-list))))
  48.  
  49. (provide 'imx6q-pads)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement