|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! o) b$ P, V* y9 x
#include <linux/init.h>+ L' }& S' E* _# e2 v
#include <linux/module.h>! Q7 Y5 [/ ~" X% b2 N5 i+ K
#include <linux/kernel.h>, C# O! Q- b" L& C$ D j7 P9 h4 A- ~: M
#include <linux/types.h>
2 L8 L' a/ g+ K. C) ?#include <linux/gpio.h>
, F9 j8 X8 l* G# L2 A#include <linux/leds.h>- D1 A B) P! F% _
#include <linux/platform_device.h>
2 j3 G8 t9 p( K$ m X9 l, k
7 A, d9 R) e' c#include <asm/mach-types.h>) [8 p. d! [; d+ s
#include <asm/mach/arch.h>
9 u) z* C" v& f: w( G#include <mach/da8xx.h>
. }! P( p: N% O, k/ h& _#include <mach/mux.h>
/ E; _8 s% m# H# u1 E
+ t1 u. C, O* l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 X0 r) G% r% l5 O( M0 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' m1 w ` b1 ]! \% f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 G- }# x+ \1 m6 X% o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ l4 Q/ d' L( p" s" i
. y, @( ]& W" S D& @( d; O# h/* assign the tl som board LED-GPIOs*/# c# n; h, P8 o/ J# b) y
static const short da850_evm_tl_user_led_pins[] = {
! P5 W( R; H9 z /* These pins are definition at <mach/mux.h> file */
+ R( ]# I& `+ l" |" } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 h0 G; Y) L5 g, f3 F$ [
-1
& i/ w" O2 O, ?3 N9 Y};
( ^( ?. o6 y% k- f6 u$ c% l! Z! ]2 b0 ^" |& S3 r/ P: Y3 e
static struct gpio_led da850_evm_tl_leds[] = {* m- ~/ i3 Z5 a* `1 c2 E7 I C
{
d5 m5 @$ c$ O' u6 K7 | .active_low = 0,
9 K& @# }2 C6 J- G% i$ n .gpio = DA850_USER_LED0,* v8 \; R8 l1 n; s" f
.name = "user_led0",- H2 i( t3 Y4 ^9 L% h" M
.default_trigger = "default-on",3 m* Y* U4 ?! i
},; Q2 ^. B: q. I
{
2 w+ W/ m, L0 d4 ~2 Y .active_low = 0,
6 C1 k8 E6 w9 N2 S# E .gpio = DA850_USER_LED1,9 `% N/ N% }5 H5 _ m
.name = "user_led1",5 r4 ?( Y$ u+ }" c
.default_trigger = "default-on",6 T! Q! S5 s9 O3 W
},) a- G; f" u$ u# J$ Y8 p
{: n( t& B% k( k! j0 Q( g
.active_low = 0,' z, V, \; @7 ~( X9 V
.gpio = DA850_USER_LED2,+ C' ?3 ]2 g8 k w f
.name = "user_led2",
8 r$ e& ~/ i/ Z- ]! N4 `9 W, O! N .default_trigger = "default-on",
! B/ @2 q. i% b, X },
1 y& g2 e6 h5 v, K7 t1 n) ~+ V4 E {
1 z+ } ~# x, Z( n0 Y' z8 f .active_low = 0,
" g. E1 B1 T( A .gpio = DA850_USER_LED3,* ~) }4 w( o/ k# `; w2 _! \. j
.name = "user_led3",
4 L, C7 {+ d: i3 e. z7 L .default_trigger = "default-on",
1 x, b" F1 |* F! O' ]1 d },' \4 W* p9 N, V* |
};
. J! A2 j/ E# e# @$ E& z2 u1 J' ~3 k E! n% E0 g" _' h1 t0 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 K( d5 k; n3 D" \0 w8 `! D; X& g! a .leds = da850_evm_tl_leds,
" N3 P3 \$ Z I- M7 H- |3 W- J" e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 M& d; w# ^8 W( Y a) _; |
};! W9 l% C) n' y% p ~ K
2 H, p- a& e R+ d5 @ x- S; ]static void led_dev_release(struct device *dev)
; p2 t, ~9 j2 }5 q7 u' |{
" E$ m$ f* B I+ w4 j, a};# N% c! s: g. G, t6 a3 f+ e) f2 i
" m" K8 X' b* [. V7 ^( L V
static struct platform_device da850_evm_tl_leds_device = {1 _$ ]2 B- |6 y' V/ {1 @
.name = "leds-gpio",
% c) Y/ x5 ~1 \/ d+ Z! f" O .id = 1,% z9 P2 s3 Q3 D% ^, a
.dev = {
3 G3 I. }: M9 F9 t .platform_data = &da850_evm_tl_leds_pdata,
; S n& t3 z8 [2 f& s2 }' W .release = led_dev_release,
& p/ R, r* ~6 Q) N }. X7 e, ]6 x; v6 b
};
6 n; s4 n: o2 ?$ ]5 ]" f B- _3 B- u1 q" B0 d( f9 _
static int __init led_platform_init(void)
2 i6 H! c1 [) c$ M" ]- u6 P( D) A{0 Z; ?5 A& k% i& R
int ret;
: k) l! h% Y5 R( f ^/ A( u4 R r#if 0
+ ]/ X5 _3 p7 H0 M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ q- k& {( ^; N% h/ I if (ret)
% Y9 V1 t4 m% S' r( l: A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! o* ]* R! P2 ~9 n- K. D4 t "%d\n", ret);+ d" F( J% G9 P! J( x) T+ b( u2 Y
#endif) @4 {3 B1 T6 c: U7 J0 n6 j- r
ret = platform_device_register(&da850_evm_tl_leds_device);* K: h: Q" Q# Y! C, [. T1 T0 w
if (ret)
6 |9 L2 C f6 ?- n$ X' _ pr_warning("Could not register som GPIO expander LEDS");
* K% d# Q$ f! H else, F& d: j" g2 h5 }+ }
printk(KERN_INFO "LED register sucessful!\n");, Y, G0 G8 C" K: N" F1 w5 z9 s
$ q- F8 U" R8 R
return ret;
$ w7 [& e1 R4 f) I/ R1 g8 }}
7 m D. Q" R0 N# Y# p; {: x6 \+ k1 s% f0 ?( a$ t9 W. V4 Q
static void __exit led_platform_exit(void)
0 Z9 I1 t4 r" R% T, p! P+ Z{' t. \' n0 X% S' k1 F* n0 _8 d
platform_device_unregister(&da850_evm_tl_leds_device);
, R. v" y0 e9 r7 t% S* g9 z/ U
8 u# N/ _3 y2 a' t: n printk(KERN_INFO "LED unregister!\n");0 I0 @! z" l* R1 e' ^+ g
}4 A4 f. M% Y( U4 D2 R
: ^+ }: h' q$ U
module_init(led_platform_init);" I3 i7 v# S# b# [$ s
module_exit(led_platform_exit);
' m1 G, f3 s* b- c/ Y
1 h1 C! b- r( {6 DMODULE_DESCRIPTION("Led platform driver");/ g( q4 b0 s0 O' @
MODULE_AUTHOR("Tronlong");
! q6 D9 F/ I3 `MODULE_LICENSE("GPL");* V+ @& w" E: W
4 V) q8 f% m7 j
|
|