|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! T4 ]0 Z2 b& ? T0 `/ ?# f#include <linux/init.h>
: I) \6 b' S7 b: l3 f#include <linux/module.h>: J+ V. T7 j% A8 ]: A' Z
#include <linux/kernel.h>
! A3 e( M L1 d: l# a#include <linux/types.h>
( g, d; Y1 Y5 q' b#include <linux/gpio.h>! j8 i3 M- A! G; b/ T
#include <linux/leds.h>
+ V9 F; t( I3 ]! o- N3 z" R* h#include <linux/platform_device.h>
/ {' S" i" }- J9 L
& P* @% _# J t f- |#include <asm/mach-types.h>8 M+ D( L- B, F
#include <asm/mach/arch.h>
7 C; m' C; j) Y#include <mach/da8xx.h>' X' Q' @! Q% O/ Q
#include <mach/mux.h>! ` f# I) j2 G/ q7 ?$ d' s
3 ?3 G* H) X: C3 n. O' ~* W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 `4 ?& K- |7 S6 V" K8 C% `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% u& v: N0 |+ v( } W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ c) a0 x1 b8 ?* h# v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ G2 o/ z- Z e! C* C5 N2 o9 S. v0 H0 w* r8 |3 f, L2 t- U/ v
/* assign the tl som board LED-GPIOs*/: V& ~( W+ |% h) K" V
static const short da850_evm_tl_user_led_pins[] = {
2 B- t6 B, x+ `$ b" Q( P, G /* These pins are definition at <mach/mux.h> file */
. f4 j9 |2 C3 t; a, J3 M1 ~ \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ b: g/ A U& O m3 W* B& _4 _7 U
-1
$ I3 C9 L3 ?: l1 i. M' J( B! i};9 R' ~7 A& [) m5 {7 k" Q; z- l
+ `1 \9 G8 K. I0 K, K
static struct gpio_led da850_evm_tl_leds[] = {! F4 P ~. A0 L/ d9 O
{" t" Q6 T1 O0 a, \
.active_low = 0,/ ~& y* O( b- O; X0 q/ T
.gpio = DA850_USER_LED0,6 X" |& c8 t% ^. b& V6 u& Q
.name = "user_led0",
/ e/ B9 H+ M9 F .default_trigger = "default-on",4 b: ~, K5 D2 C1 Z9 ~9 |
},. L) W# j6 F: E# z
{
, j z2 N! E& f# P1 @ .active_low = 0,
. k$ u9 O8 I9 R .gpio = DA850_USER_LED1,6 U/ [3 @( B* R* p! k
.name = "user_led1",
: J% c# A1 h# P/ }4 ]; o/ m5 z" [ .default_trigger = "default-on",+ T7 j* i! v% \& a9 D( a8 } P
},* ]5 W, Z# D* }8 `- k: c7 W
{% n! X. f! @! }2 I
.active_low = 0,
b0 b5 N- Z1 Z9 T; }" ^) o0 { .gpio = DA850_USER_LED2," R6 W2 S$ Q* U, \9 C3 V
.name = "user_led2",
% V$ V+ q, E& r9 O! n .default_trigger = "default-on",- d. `! }/ Q/ V! W7 d4 ^
},9 I- V) B) }4 i& M! _
{' |2 V$ h( o2 R
.active_low = 0,7 r. L$ ~6 i e3 l! b
.gpio = DA850_USER_LED3,' \' [$ X6 W: Q9 i5 n
.name = "user_led3",
. x# G; h" I# V! L r& ^ .default_trigger = "default-on",
5 p9 ^) Y6 I. X/ f; u R },# S6 A7 C- E7 I' ^4 W1 E
};
, T" _$ ^. c8 l) `
5 ]7 |% t0 F+ E7 ^& h! Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' X* k/ z8 I7 u6 { .leds = da850_evm_tl_leds,
. t. K; Y) Y- T8 j5 u" @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# L! m4 Y* |2 p [3 R7 P
};. t8 Q) r6 @" w: U( A
& o2 A! s5 Z3 A$ fstatic void led_dev_release(struct device *dev). x& \; n6 P; d. }& S
{) L0 f; m/ \. L. L5 R, |7 H
};7 ~) |# M7 H4 ^
/ d: C3 h( y9 j5 }5 `static struct platform_device da850_evm_tl_leds_device = {0 L& ^& L- {$ p
.name = "leds-gpio",7 r' R& f! Q5 g9 x" z
.id = 1,- O% m* K: k- H% N9 W* d; ~8 @
.dev = {
( H% I7 t& ~* f( _ .platform_data = &da850_evm_tl_leds_pdata,- H+ i+ C; `- l9 g; R3 e& Q3 ^7 a
.release = led_dev_release,
% a( a/ g+ K" {8 h }* h4 g8 V" D; s' U
};2 p. Q% ?0 N, O
) [+ L/ D0 `$ q) S5 f# Dstatic int __init led_platform_init(void)
- c$ b5 y( C& s S) n; y: J( g$ R{9 W% L3 @$ m! O4 W
int ret;
4 r& _2 [; i5 {& R X5 G# W9 X. T1 B#if 02 \, M& q, A; }9 |2 C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' s: G* G. ~. a5 i6 f2 l- f0 S
if (ret): d" Q5 M0 H- @0 ?8 o0 T- ?# k% P |) ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ D( V! s' W) _ "%d\n", ret);% h# p, @8 ~3 p
#endif) x, z6 J/ `! @! h& I
ret = platform_device_register(&da850_evm_tl_leds_device);4 b0 C" ? D* k+ a
if (ret)4 p/ s+ D* V7 ^- c
pr_warning("Could not register som GPIO expander LEDS");1 d& J7 H6 _/ I4 r1 l! x/ P% Z3 g% w
else9 F: g3 D# t2 {
printk(KERN_INFO "LED register sucessful!\n");! i. c, v1 i' J# V. T' s
/ \! f0 d9 Y$ g: d. k return ret;
/ `7 S: k8 h* g$ m" N) B% q}
: J. _. @. h/ I
8 b6 V9 m& V+ h* U! j% q& R& }static void __exit led_platform_exit(void)
* L1 R) [+ B5 l7 o8 K8 @( `7 j2 C; [{( w9 w: T$ G1 ^ \3 A
platform_device_unregister(&da850_evm_tl_leds_device);
4 X8 m. d- N$ |3 S" t: ?* R+ Y" T# N ^& g' h4 D
printk(KERN_INFO "LED unregister!\n");
4 U$ ]* T+ ?% k5 E, e}4 b6 p2 F- R$ C; d" ? n
, X! X% z" {- {) j! M* Zmodule_init(led_platform_init);
8 ?8 ]/ M' H$ a5 `/ c* k2 I/ B5 n3 m* xmodule_exit(led_platform_exit);
: B$ k- i. j! K$ ]+ q* |( i, R, ?" L- S0 W
MODULE_DESCRIPTION("Led platform driver");
9 t8 Q7 h: X# i9 s/ z7 N- DMODULE_AUTHOR("Tronlong");) n7 o6 X% \( n( Z4 k+ `& {
MODULE_LICENSE("GPL");* }+ h, X( L O0 L
3 _! y8 o) i& q- k' o! l |
|