|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 [! b0 L* e; v#include <linux/init.h>
! @. \1 c8 T7 q' o#include <linux/module.h>
, h u; p5 f& {#include <linux/kernel.h>
1 N$ p' H0 ^4 p8 T' c" m4 D#include <linux/types.h>
: F0 Y/ L2 L' g5 [#include <linux/gpio.h>
9 c5 J; ^9 t% Q. |#include <linux/leds.h>, X# z1 {: ]1 T% ~" N
#include <linux/platform_device.h>
" u$ I" {5 Y2 x2 m! ~ T
8 Z0 Z+ E N+ P* w8 ?3 D: Y$ l#include <asm/mach-types.h>
+ M6 Z) u4 O. u* P#include <asm/mach/arch.h> F! } l2 q4 I" Z: \' ~1 |: d: i
#include <mach/da8xx.h>" y: q7 N' p" n+ w) `$ R+ Y
#include <mach/mux.h>
8 a( u3 _( ], F# ~7 m; M W& ^* ~2 W9 L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 C8 ^7 H6 Z6 d4 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ I! x6 q& g) o; r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" \& M+ r0 b- W8 V/ Q# A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( }: ?6 u, Q3 S) A9 D; I( \) U7 [8 T
/* assign the tl som board LED-GPIOs*/
# M: f$ a7 |9 R7 S4 A! ostatic const short da850_evm_tl_user_led_pins[] = {
' b! w/ k! ~/ P) o- Z /* These pins are definition at <mach/mux.h> file */
3 S: `& C% o( W" O4 F3 Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 Y' N$ f$ h! |' W' J
-1
! L2 Q7 ~8 `3 }" M: z};
$ U" T+ ?7 U! _
( o9 d- t7 {' f3 g+ gstatic struct gpio_led da850_evm_tl_leds[] = {
- r V K, U9 Q/ ]! g' L; S8 t" L5 b {- v4 a. d( |* @- U" z: X& e" y- F
.active_low = 0,8 g7 D. V6 g5 X: y
.gpio = DA850_USER_LED0,* ~3 B; q& A. y. B9 c$ {. a) N
.name = "user_led0",
2 g6 x. m2 G. j .default_trigger = "default-on",/ a; w1 L; S9 v
},2 c8 p' V, x! T7 q
{$ S6 ]2 X" {8 a; m* U) Z9 h6 ]8 ?
.active_low = 0,. f' t) _) p, o! K P+ G! v+ C
.gpio = DA850_USER_LED1,- w% \# E3 T, j
.name = "user_led1",
7 B# K1 S7 i/ |, u1 h) v: k .default_trigger = "default-on",
1 w5 G9 F+ @4 r% O: C4 G },( {$ @9 M# Z( r# o
{; _2 n3 ^% o: n4 R j" Z3 G* C
.active_low = 0,2 r k2 L4 V6 J& O) m
.gpio = DA850_USER_LED2,5 b5 K! p) g% u3 A
.name = "user_led2",: n; k2 h- o5 o1 k
.default_trigger = "default-on",! O( Q5 T R$ U) V8 q1 o' _ E3 N% C# R
},
/ T4 T' d7 T1 F. G) l {
9 h* N: i8 m" c4 e8 U! v5 p% f .active_low = 0,
) d% h* ~1 E w8 p0 p- q, @ .gpio = DA850_USER_LED3,
- a6 ?" @* F- c- I9 M .name = "user_led3",
i2 [6 V# ?) ~/ v$ K/ P0 v# Y+ m .default_trigger = "default-on",
, j! t2 O# r7 q6 x- ^* n$ v) c },
2 B# H* \! u% I/ U' `) O8 u};
" k% j, e, `8 K: o7 n0 w
' R; A. b% A [& A S. Y2 J* D1 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 K$ @, z6 S( {
.leds = da850_evm_tl_leds,
) ^$ R2 s2 c; a. r3 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; t3 q2 b# S: @# q; d! h; x( P};( ]! {7 j4 E. {! E: d* }, w% m
! j) ` c( u/ v8 B# O8 [static void led_dev_release(struct device *dev)
9 q) a7 m2 ?6 B: R$ `. R! x; n; T0 H{
' f& H1 Q* B# p) p n, Z};
5 G: P1 s2 n/ x* ]& q- q9 K
2 y0 b: J8 M1 Lstatic struct platform_device da850_evm_tl_leds_device = {/ F/ T2 c0 z* A
.name = "leds-gpio",% S% u6 Y9 d/ X2 { A5 j, a
.id = 1,
: n2 d$ B( V! o .dev = {) r4 v+ R, A* H* d6 y
.platform_data = &da850_evm_tl_leds_pdata,
$ J9 w2 }; O- c0 B- H) v' j .release = led_dev_release,- S: k6 r6 D) T0 V* g! r K
}
" K% l; X+ r, X+ z7 q0 X' W' J};! M6 \* o+ `" ]/ O
# I5 Q m" G. [! A
static int __init led_platform_init(void) ]7 V8 {* {0 X' f
{
. V7 M/ N+ {% Y4 z int ret;
g& ~2 \! F" o& S9 \& i1 y9 u#if 0+ A% `3 Y8 I" d7 d# Q, K1 y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 O9 {! V1 W" i/ U6 Z. G
if (ret)! j' i0 p% B! b4 \' D2 ^; x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( y2 V: Q N9 ]7 G) | "%d\n", ret);$ p0 M+ ]$ z0 b" l! r3 M$ x) Y2 g
#endif) ]5 B: T% Z/ p! N/ @1 v# m `9 y
ret = platform_device_register(&da850_evm_tl_leds_device);4 k; K- U+ |2 Y! z0 e
if (ret)2 F% m9 h* @3 l' c1 L
pr_warning("Could not register som GPIO expander LEDS");/ g) S+ I" F# |+ c5 j$ \
else& H# n* y- l5 W2 ^) R B" {/ _& _
printk(KERN_INFO "LED register sucessful!\n");) D0 x X" x4 n! F+ R
& Z" G/ L" J8 w, D return ret;
/ n: g. h: O8 h& a2 H% i4 S( l& A}$ b# a" t% Y' O$ u5 {
: K' }) f6 o i8 f. Istatic void __exit led_platform_exit(void)
) |+ T4 S" A' ]2 t2 Q; w: o{
z, {+ c7 i! }# V platform_device_unregister(&da850_evm_tl_leds_device);8 Z/ Y- C5 m" ]' j
5 a: `- q4 W# ^% l7 P# C" x
printk(KERN_INFO "LED unregister!\n");
- t0 A4 G2 T6 O# ~}" D5 X3 C; U- D" C& m
) o3 n/ i4 h5 r: i4 x$ ^
module_init(led_platform_init);
! Y9 a, `" V& zmodule_exit(led_platform_exit);
. w/ Y2 W; N/ g6 B* A4 N/ |5 t6 c$ A# s- ?
MODULE_DESCRIPTION("Led platform driver");
( d' n( y, }$ z: u: pMODULE_AUTHOR("Tronlong");- c4 ^! h6 ]% ?5 |$ m. z+ O" N
MODULE_LICENSE("GPL");3 a! H! `7 Y' J0 n$ M/ G' N" } e
7 q n( b$ Q& d, z6 b3 k |
|