|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# p7 D) s+ W' s) c' Y, Y$ K8 t
#include <linux/init.h>
@# b5 ?% j; u# L5 ^' ~#include <linux/module.h> C$ ?) {" c9 y
#include <linux/kernel.h>
% V% A6 r/ q1 ?& Y7 F6 G#include <linux/types.h>+ L) |# p! b' s: w1 e7 `) X
#include <linux/gpio.h>
" i U9 K- C1 [% u#include <linux/leds.h>, C0 I* e2 {- a: R
#include <linux/platform_device.h>
0 _& d& M P# {* K6 M) _+ d( u [2 l: l
#include <asm/mach-types.h>2 T; b9 ?" w: Q4 f
#include <asm/mach/arch.h>
' a, I+ R2 H0 T3 p#include <mach/da8xx.h>
7 v9 ^8 f, `! Z1 Q: q" u#include <mach/mux.h>
/ W: n6 Z- r& u- _9 e
9 s$ t% w$ X( A8 D. b' A7 G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ n5 g2 \1 I' d" B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ O- _% D: v. _4 M! ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ T' P. U/ s6 v9 M4 |8 V9 a' W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ d. |( e) c. |; ~
! k I; O+ k4 I, T( R* o9 ^: e7 |* Y
/* assign the tl som board LED-GPIOs*/' \1 A6 o, h9 A! f' J" x' @
static const short da850_evm_tl_user_led_pins[] = {0 ?% A! ~- [, U; m' _3 m- B C
/* These pins are definition at <mach/mux.h> file */
5 X6 ^- t+ B: t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* y" U$ h* M2 ~2 i- v3 i$ Y# \; v -1
. l4 m/ ^, o* x- Y. P& I; v};
4 ~& Y! j% E' f+ c
% M! W+ N# v- |# k4 l: lstatic struct gpio_led da850_evm_tl_leds[] = {3 Q7 ?+ m* P! L' t6 _
{
2 ^( c8 X, Q v .active_low = 0,; I' W/ J0 ~$ R( m/ p0 | ]+ L
.gpio = DA850_USER_LED0,
, e. z4 Y3 J6 v6 ? .name = "user_led0",
& X7 U2 H) S4 @' i& j9 w .default_trigger = "default-on",
8 ?; z/ \) h1 s+ K- } },5 C6 L9 m5 _+ i2 C2 f4 s$ }" y
{* |, r3 x) k# J! I+ l
.active_low = 0,
4 }. U; h: R7 x- Y) Z2 ? .gpio = DA850_USER_LED1,7 k- G3 O' K% A5 L
.name = "user_led1",
# e0 ^- p/ A- t( d# ^( ^3 Q .default_trigger = "default-on",
5 H9 W& x8 r8 V/ m$ b },# A! a7 W X. U0 l* p& `
{# }6 m# c6 y" a2 c
.active_low = 0,/ p8 F* J6 Z# ^0 w; Q0 V; {
.gpio = DA850_USER_LED2,
+ T% O1 L' I& f* \6 N .name = "user_led2",# S7 M/ d; \ V- e' E* a% [4 C
.default_trigger = "default-on",$ w% b6 P1 g% a7 r' O
},* }0 S5 T$ M& V$ k, Z
{8 F2 i! E8 z5 \ P, e6 Q0 c+ w0 v/ [
.active_low = 0,9 D' C N) r4 v7 h5 }: }
.gpio = DA850_USER_LED3,
( b, b7 \; f3 h .name = "user_led3",% `* X1 `4 e/ m9 r, r2 r, b
.default_trigger = "default-on"," V4 W1 ] Y! I3 h6 c+ l3 u
},7 @* z8 u) \) A7 K) d
};
9 b9 w+ h+ a. k# r
* C& q% B) ^: B& @5 {" L6 M; O+ dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 l7 T3 i; R: s9 {0 A7 T; R .leds = da850_evm_tl_leds,
. i. {: h5 H$ |3 a) A- [" P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 A4 v: d3 ~- u Z! S7 ]& c};
. G* n" p. y0 l" h
% B: P9 J: a: }3 h3 `% Y7 o1 ]static void led_dev_release(struct device *dev)7 V, g8 k8 g! s7 o: `
{: a% s" p* ~( @. C6 r( o
};
" D) V) w/ W9 t u n
) V% i0 F* P, istatic struct platform_device da850_evm_tl_leds_device = {) T0 F, y7 T4 k* [/ N2 O* Y
.name = "leds-gpio",5 c2 _; H; a8 L. b/ l2 s
.id = 1,
( ]" u5 A6 l7 g% V( b, G% |+ S. ]9 d .dev = {
) A" R' J6 w0 D .platform_data = &da850_evm_tl_leds_pdata,; G5 G+ J: S7 W* f
.release = led_dev_release,, m$ g4 u. g7 _5 @ R% [
}
7 h& X: ]7 p; ?" u! M0 h% T};
. W7 k* W% B$ \5 Y! ~. d4 z( b# G0 s1 e. n% y) r6 o0 V
static int __init led_platform_init(void)
( e; X1 d1 D% H! r4 Z{' E5 z* e6 r2 c0 O
int ret;8 d k8 k% }- q( x+ f0 `
#if 0( ~4 R- ?' G: u% M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 v& d- l: F) a: U7 v
if (ret)
, [* B1 E# D/ A e5 w9 p" i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 q( u0 u0 ~8 Y! k: _
"%d\n", ret);
; x& w. x v" V+ |0 C; Z3 j0 k#endif' Y% w* O) }& l" Y6 A
ret = platform_device_register(&da850_evm_tl_leds_device);
$ G& Z9 i+ l; b8 f* V5 e+ D if (ret)9 t# a* _- \' L2 c4 q [
pr_warning("Could not register som GPIO expander LEDS");
! e$ |: w9 ]% s; B else
8 E' ~# E9 O1 Q$ V' |1 s/ } printk(KERN_INFO "LED register sucessful!\n");
- X% l; a0 O# W% @- e; |/ J
. [. C! N9 \7 y/ l return ret;
7 ~) K8 x' f# f/ u}2 q7 K& y8 p e/ e8 a+ @
, a: ^/ K/ c' u! r/ m
static void __exit led_platform_exit(void)/ }# G2 E/ A6 W7 J+ a) \
{
! x& R, R5 I# ~$ e7 c4 s& J. W1 W platform_device_unregister(&da850_evm_tl_leds_device);$ M- y4 [, q0 h- V4 h- U) t
! v! M# L9 M1 f1 s, g
printk(KERN_INFO "LED unregister!\n");
; B* B% ]5 p0 |9 k& H}
( d; r- y1 L+ {3 T
: P! z5 B {8 O0 G. smodule_init(led_platform_init);
+ Q" O1 T" r8 s4 W1 B: Dmodule_exit(led_platform_exit);
7 A) [2 Z: ]1 E1 t3 g j) ?9 H1 h" n4 l+ J, Y" n" v9 g7 ]2 w. d
MODULE_DESCRIPTION("Led platform driver");) H1 z6 d [6 R, N# }( e8 t
MODULE_AUTHOR("Tronlong");6 S2 y; u- Y1 j& m! j* q' a: r
MODULE_LICENSE("GPL");
$ K# g9 z. r2 u$ Q- h3 T- M
5 Q+ d9 h* _8 O# u" \( ] |
|